/* AI Assistant with unified single scrollable container */
.ai-container {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-radius: 16px;
    border: 1px solid #374151;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Subtle background pattern */
.ai-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(196, 173, 43, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(196, 173, 43, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

/* Main scrollable chat area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #0a0a0a;
    position: relative;
    z-index: 1;
}

/* Compact header inside chat area */
.ai-header-inline {
    text-align: center;
    margin-bottom: 32px;
    padding: 24px;
    background: rgba(31, 41, 55, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid #374151;
}

.ai-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #0a0a0a;
    border: 2px solid rgba(196, 173, 43, 0.3);
    box-shadow: 0 6px 16px rgba(196, 173, 43, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ai-title {
    font-size: 24px;
    font-weight: 700;
    color: #f9fafb;
    margin: 0 0 8px 0;
    font-family: 'Sen', sans-serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ai-subtitle {
    color: #d1d5db;
    font-size: 14px;
    margin: 0;
    font-weight: 400;
    opacity: 0.9;
}

/* Suggested questions inline */
.suggestions-inline {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.suggestion-pill {
    padding: 8px 12px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 16px;
    font-size: 12px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.suggestion-pill:hover {
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    color: #0a0a0a;
    border-color: #c4ad2b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(196, 173, 43, 0.3);
}

.welcome-state {
    text-align: center;
    color: #94a3b8;
    font-size: 16px;
    padding: 40px 24px;
    line-height: 1.6;
    font-weight: 400;
    background: rgba(31, 41, 55, 0.3);
    border-radius: 12px;
    border: 1px solid #374151;
    margin-bottom: 24px;
}

/* Message bubbles */
.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.user-bubble {
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    color: #0a0a0a;
    padding: 12px 16px;
    border-radius: 18px 18px 6px 18px;
    max-width: 75%;
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(196, 173, 43, 0.2);
}

.ai-message {
    display: flex;
    justify-content: flex-start;
}

.ai-bubble {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f1f5f9;
    padding: 16px 20px;
    border-radius: 18px 18px 18px 6px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.6;
    border: 1px solid #475569;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

/* Sources section */
.sources-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #475569;
}

.sources-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    color: #c4ad2b;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sources-header:hover {
    color: #d4bd3b;
}

.source-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
    border: 1px solid transparent;
}

.source-item:hover {
    background: rgba(71, 85, 105, 0.3);
    border-color: #c4ad2b;
    transform: translateX(4px);
}

.source-avatar {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #0a0a0a;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.source-content {
    flex: 1;
    min-width: 0;
}

.source-title {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 4px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-snippet {
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.source-meta {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

/* Loading state */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 18px 18px 18px 6px;
    max-width: 160px;
    color: #cbd5e1;
    font-size: 14px;
    border: 1px solid #475569;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #c4ad2b;
    border-radius: 50%;
    animation: typing 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 typing {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* Error message */
.error-message {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
    color: #fecaca;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #b91c1c;
    font-size: 14px;
    margin: 12px 0;
    box-shadow: 0 4px 12px rgba(127, 29, 29, 0.3);
}

/* Sticky input section at bottom */
.input-section {
    padding: 20px 24px;
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #374151;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.input-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.question-input {
    width: 100%;
    height: 48px;
    padding: 12px 52px 12px 16px;
    border: 2px solid #374151;
    border-radius: 24px;
    font-size: 15px;
    background: #0f172a;
    color: #f8fafc;
    outline: none;
    transition: all 0.3s ease;
    font-family: 'Sen', sans-serif;
    font-weight: 400;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.question-input:focus {
    border-color: #c4ad2b;
    box-shadow: 0 0 0 4px rgba(196, 173, 43, 0.1), inset 0 2px 4px rgba(0, 0, 0, 0.1);
    background: #1e293b;
}

.question-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.send-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    border: none;
    border-radius: 18px;
    color: #0a0a0a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(196, 173, 43, 0.3);
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #d4bd3b 0%, #e4cd4b 100%);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(196, 173, 43, 0.4);
}

.send-btn:disabled {
    background: #4b5563;
    cursor: not-allowed;
    color: #6b7280;
    transform: translateY(-50%) scale(1);
    box-shadow: none;
}

/* Reference links styling */
.reference-links {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #475569;
}

.reference-links-label {
    font-size: 13px;
    color: #c4ad2b;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reference-links-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.reference-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: linear-gradient(135deg, #c4ad2b 0%, #d4bd3b 100%);
    color: #0a0a0a;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(196, 173, 43, 0.2);
    min-width: 32px;
}

.reference-link:hover {
    background: linear-gradient(135deg, #d4bd3b 0%, #e4cd4b 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(196, 173, 43, 0.3);
}

/* Enhanced scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #c4ad2b;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .ai-container {
        height: 75vh;
        border-radius: 12px;
    }

    .chat-container {
        padding: 16px;
    }

    .ai-header-inline {
        padding: 16px;
        margin-bottom: 24px;
    }

    .ai-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .ai-title {
        font-size: 20px;
    }

    .ai-subtitle {
        font-size: 13px;
    }

    .input-section {
        padding: 16px;
    }

    .question-input {
        height: 44px;
        font-size: 14px;
        padding: 10px 48px 10px 14px;
    }

    .send-btn {
        width: 32px;
        height: 32px;
        right: 6px;
    }

    .user-bubble,
    .ai-bubble {
        max-width: 90%;
        font-size: 14px;
    }

    .suggestion-pill {
        font-size: 11px;
        padding: 6px 10px;
    }

    .welcome-state {
        padding: 24px 16px;
        font-size: 14px;
    }
}
