/**
 * CyberGuard AI Chatbot Styles
 * Custom styling for the AI chatbot interface
 */

/* Chat-specific styling */
.chat-container {
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

/* Custom scrollbar for chat messages */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Message styling */
.chat-message {
    animation: fadeInUp 0.3s ease-out;
    margin-bottom: 1rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User message styling */
.chat-message.user-message {
    justify-content: flex-end;
}

.chat-message.user-message .message-content {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    border-radius: 18px 18px 6px 18px;
    max-width: 70%;
    word-wrap: break-word;
}

/* Assistant message styling */
.chat-message.assistant-message .message-content {
    background: rgba(30, 41, 59, 0.8);
    color: #f8fafc;
    border-radius: 18px 18px 18px 6px;
    max-width: 80%;
    word-wrap: break-word;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Error message styling */
.chat-message.error-message .message-content {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 18px 18px 18px 6px;
    max-width: 80%;
}

/* Message content styling */
.message-content {
    padding: 0.875rem 1.125rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.message-content p {
    margin: 0 0 0.5rem 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Code blocks in messages */
.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Avatar styling */
.message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.assistant-avatar {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.user-avatar {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
}

.error-avatar {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

/* Timestamp styling */
.message-timestamp {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    space-x: 0.5rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.typing-dots {
    display: flex;
    space-x: 0.25rem;
}

.typing-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat input area */
.chat-input-area {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 41, 59, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.chat-input {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    resize: none;
    min-height: 2.5rem;
    max-height: 8rem;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

.chat-input::placeholder {
    color: rgba(248, 250, 252, 0.5);
}

/* Send button */
.send-button {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    transition: all 0.2s ease;
    border: none;
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Quick actions sidebar */
.quick-actions {
    background: rgba(30, 41, 59, 0.8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-action-btn {
    background: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    background: rgba(71, 85, 105, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    space-x: 0.5rem;
}

.status-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
}

.status-online {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
    animation: pulse 2s infinite;
}

.status-offline {
    background: #dc2626;
}

.status-error {
    background: #f59e0b;
    animation: blink 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0.3;
    }
}

/* API Key Modal */
.api-modal {
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    background: rgba(0, 0, 0, 0.5);
}

.api-modal-content {
    background: rgba(30, 41, 59, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.api-key-input {
    background: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.api-key-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Responsive design */
@media (max-width: 1024px) {
    .chat-layout {
        flex-direction: column;
    }
    
    .quick-actions {
        order: 2;
        margin-top: 1rem;
    }
    
    .chat-interface {
        order: 1;
    }
}

@media (max-width: 768px) {
    .chat-messages {
        padding: 0.75rem;
    }
    
    .message-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
    }
    
    .chat-input-area {
        padding: 0.75rem;
    }
    
    .quick-actions {
        padding: 1rem;
    }
    
    .quick-action-btn {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 640px) {
    .page-header h1 {
        font-size: 1.875rem;
    }
    
    .page-header p {
        font-size: 1rem;
    }
    
    .chat-input {
        font-size: 1rem;
    }
    
    .send-button {
        padding: 0.75rem 1rem;
    }
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Accessibility improvements */
.chat-input:focus-visible,
.send-button:focus-visible,
.quick-action-btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Dark mode enhancements */
@media (prefers-color-scheme: dark) {
    .chat-messages::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .chat-messages::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .chat-messages::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.25);
    }
}

/* Print styles */
@media print {
    .quick-actions,
    .chat-input-area,
    .api-modal {
        display: none !important;
    }
    
    .chat-messages {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .chat-message {
        break-inside: avoid;
    }
}