/* Theme and Variables */
:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --border-glass: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(15, 23, 42, 0.6);
    --bg-glass-hover: rgba(30, 41, 59, 0.8);
    --font-primary: 'Outfit', 'Plus Jakarta Sans', sans-serif;
    --font-secondary: 'Plus Jakarta Sans', sans-serif;
    --sidebar-width: 320px;
    --glow-color-1: rgba(59, 130, 246, 0.15);
    --glow-color-2: rgba(139, 92, 246, 0.15);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Glow Effects */
.bg-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    z-index: 0;
    pointer-events: none;
}

.bg-glow-1 {
    width: 600px;
    height: 600px;
    background: var(--glow-color-1);
    top: -10%;
    left: -10%;
}

.bg-glow-2 {
    width: 500px;
    height: 500px;
    background: var(--glow-color-2);
    bottom: -10%;
    right: -10%;
}

/* Common Glassmorphism Container styling */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px stroke var(--border-glass);
    border: 1px solid var(--border-glass);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 1. Loading Screen styling */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-container {
    width: 90%;
    max-width: 480px;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-wrapper {
    margin-bottom: 24px;
}

.logo-icon {
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}

.loading-container h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 30%, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loading-container p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 30px;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 3px;
    transition: width 0.3s ease;
}

.status-text {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-secondary);
}

/* 2. Main App Container styling */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.hide {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* Sidebar styling */
.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    z-index: 20;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-glass);
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-content {
    padding: 24px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-content h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 12px;
    margin-top: 24px;
}

.sidebar-content h3:first-of-type {
    margin-top: 0;
}

.about-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.docs-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.docs-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.docs-list li:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-glass);
}

.doc-icon {
    font-size: 20px;
}

.doc-info {
    display: flex;
    flex-direction: column;
}

.doc-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.doc-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-glass);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
}

/* Chat Main Area */
.chat-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.chat-header {
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-glass);
}

.header-info h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.config-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Message History styling */
.chat-messages {
    flex-grow: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    align-self: flex-start;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.message.user-message .avatar {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
}

.message-content {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message.user-message .message-content {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

/* Welcome Suggestions */
.suggestions-title {
    margin-top: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
}

.suggestions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.suggestion-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--accent-blue);
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

/* Citation / Sources Container */
.citations-box {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.citations-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.citations-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.citation-item {
    font-size: 12px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.citation-item:hover {
    color: var(--text-primary);
}

/* Expanded Chunk view on citation click */
.chunk-details {
    display: none;
    margin-top: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    font-family: var(--font-secondary);
}

.chunk-details.show {
    display: block;
}

/* Input Form Area styling */
.chat-input-area {
    padding: 24px 32px;
    border-top: 1px solid var(--border-glass);
}

.chat-form {
    display: flex;
    gap: 16px;
    align-items: center;
}

#query-input {
    flex-grow: 1;
    background: rgba(2, 6, 23, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 16px 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-primary);
    outline: none;
    transition: all 0.2s ease;
}

#query-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Typing / Loading Indicators */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    animation: bounce 1.3s infinite both;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Keyframe Animations */
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

.animate-pulse {
    animation: pulse 2s infinite ease-in-out;
}

/* Mobile Responsive Media Queries */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    body {
        align-items: stretch;
    }

    .app-container {
        flex-direction: column;
        position: relative;
        width: 100%;
        height: 100dvh; /* dynamic viewport height */
    }

    /* Sidebar Mobile adjustments (Collapsible overlay) */
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Menu toggle button for Mobile */
    .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-glass);
        cursor: pointer;
        color: var(--text-primary);
        transition: background 0.2s ease;
    }

    .menu-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    /* Close sidebar button inside mobile header */
    .close-sidebar-btn {
        display: block !important;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 24px;
        cursor: pointer;
        padding: 4px;
    }

    /* Chat Area Layout adjustments */
    .chat-header {
        padding: 16px 20px;
        gap: 12px;
    }

    .header-info h1 {
        font-size: 16px;
    }

    .header-info p {
        font-size: 11px;
    }

    .config-badge {
        display: none; /* Hide configuration details on mobile to save space */
    }

    .chat-messages {
        padding: 20px 16px;
        gap: 16px;
    }

    .message {
        max-width: 95%;
    }

    .message-content {
        padding: 12px 16px;
        font-size: 13.5px;
    }

    .chat-input-area {
        padding: 16px;
    }

    .chat-form {
        gap: 10px;
    }

    #query-input {
        padding: 12px 16px;
        font-size: 13.5px;
        border-radius: 12px;
    }

    .send-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .suggestions-container {
        flex-direction: column;
        align-items: stretch;
    }

    .suggestion-btn {
        width: 100%;
        text-align: left;
    }

    /* Loading screen mobile styling */
    .loading-container {
        padding: 24px;
    }

    .loading-container h2 {
        font-size: 20px;
    }
}

/* Base styles for new components to support mobile layout (hidden by default on desktop) */
.menu-toggle {
    display: none;
}

.close-sidebar-btn {
    display: none;
}

