:root {
    /* Color Palette - Clean, Professional ChatGPT/Claude Aesthetic */
    --bg-main: hsl(0, 0%, 9%);               /* ChatGPT Deep Charcoal (#171717) */
    --bg-panel: hsl(0, 0%, 13%);             /* ChatGPT Sidebar/Panel (#202020) */
    --bg-panel-hover: hsl(0, 0%, 16%);       /* Flat hover gray */
    --bg-input: hsl(0, 0%, 14%);             /* Clean, borderless input (#242424) */
    
    --text-primary: hsl(0, 0%, 93%);         /* Clean Off-White */
    --text-secondary: hsl(0, 0%, 75%);       /* Subtle Muted Gray */
    --text-muted: hsl(0, 0%, 55%);           /* Professional Dark Slate Gray */
    
    --accent-primary: hsl(160, 60%, 45%);     /* Clean ChatGPT/CPCB Green (#10a37f) */
    --accent-secondary: hsl(215, 60%, 50%);   /* Professional Slate Royal Blue */
    --accent-tertiary: hsl(38, 80%, 50%);     /* Amber Accent Highlight */
    
    --border-color: rgba(255, 255, 255, 0.08); /* 1px very thin borders */
    --border-glow: transparent;              /* Zero glowing neon outlines */
    
    --success: hsl(160, 60%, 45%);
    --warning: hsl(38, 80%, 50%);
    --error: hsl(0, 80%, 55%);

    /* Metrics */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    --shadow-glow: none;                     /* Zero neon glowing shadows */
    --shadow-panel: 0 4px 24px rgba(0, 0, 0, 0.2);

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Clean, solid background - zero neon AI gradients */
}

/* Base Panel Class */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 100%; /* Fill screen for a clean, spacious look */
    margin: 0 auto;
}

/* ── Sidebar ── */
.sidebar {
    width: 260px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel); /* Clean flat color */
    z-index: 10;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h2 {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-heading);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h1, h2, h3 {
    font-family: var(--font-heading);
}

.sidebar-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.nav-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-panel);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.status-indicator.online .dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.action-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-panel-hover);
    border-color: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.clear-cache-btn {
    border-color: rgba(239, 68, 68, 0.22);
    background: rgba(239, 68, 68, 0.08);
}

.clear-cache-btn:hover {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.14);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.16);
}

.action-btn.small {
    padding: 10px 12px;
    font-size: 0.8rem;
}

.ghost-btn {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ghost-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
}

.hidden {
    display: none !important;
}

.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.auth-actions {
    display: grid;
    gap: 8px;
}

.upload-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: -10px;
}

.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.nav-section-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mini-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

.docs-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 16px;
    margin-bottom: 8px;
}

.docs-status.success {
    color: var(--success);
}

.docs-status.error {
    color: var(--error);
}

.docs-status.warning {
    color: var(--warning);
}

.docs-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-panel);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.doc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.session-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.doc-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.session-item {
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.session-item.active {
    border-color: var(--accent-primary);
}

.session-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    color: inherit;
}

.session-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-delete-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 8px 8px 8px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.session-delete-btn:hover {
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

.doc-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.doc-row-main {
    flex: 1;
    min-width: 0;
}

.doc-delete-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.doc-delete-btn:hover {
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
}

.feedback-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 4px;
}

.feedback-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font-size: 0.75rem;
}

.feedback-query,
.feedback-response {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feedback-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.feedback-escalation {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    font-size: 0.65rem;
    font-weight: 600;
}

.msg-feedback {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding: 0 4px;
    font-size: 0.75rem;
}

.msg-feedback-label {
    color: var(--text-muted);
    margin-right: 4px;
}

.feedback-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.feedback-btn:hover:not(:disabled) {
    border-color: var(--border-glow);
    background: var(--bg-panel-hover);
}

.feedback-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feedback-btn.feedback-escalate {
    font-size: 0.7rem;
    padding: 2px 10px;
}

.star-rating {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.star-btn {
    font-size: 1.15rem;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.15s ease;
    user-select: none;
}

.star-btn:hover,
.star-btn.hovered {
    color: #f1c40f; /* warm premium gold */
    transform: scale(1.25);
}

.msg-feedback-status {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.msg-feedback-status.success {
    color: var(--success);
}

.msg-feedback-status.error {
    color: var(--error);
}

.doc-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.doc-status.success { color: var(--success); }
.doc-status.warning { color: var(--warning); }
.doc-status.error { color: var(--error); }

.doc-progress {
    margin-top: 8px;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.doc-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transition: width 0.2s ease;
}

.doc-progress-bar.warning {
    background: linear-gradient(90deg, var(--warning), var(--accent-secondary));
}

.doc-progress-bar.error {
    background: linear-gradient(90deg, var(--error), #ff9aa2);
}

.doc-progress-bar.indeterminate {
    width: 100%;
    background-size: 200% 100%;
    animation: progress-sweep 1.2s linear infinite;
}

@keyframes progress-sweep {
    0% { background-position: 0% 0; }
    100% { background-position: 100% 0; }
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Main Chat Area ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(11, 14, 20, 0.6);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.chat-header-title {
    min-width: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: nowrap;
}

.auth-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.topbar-actions .action-btn,
.topbar-actions .ghost-btn {
    width: auto;
    white-space: nowrap;
}

.topbar-actions .admin-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-upload-status {
    margin-top: 4px;
}

.chat-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.chat-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

@media (max-width: 1100px) {
    .chat-header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .auth-inline {
        width: 100%;
        justify-content: space-between;
    }
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 8px;
}
.chat-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-main);
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Sidebar Content Scrollbar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}
.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
}
.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Document List Scrollbar */
.doc-list::-webkit-scrollbar,
.feedback-list::-webkit-scrollbar {
    width: 5px;
}
.doc-list::-webkit-scrollbar-track,
.feedback-list::-webkit-scrollbar-track {
    background: transparent;
}
.doc-list::-webkit-scrollbar-thumb,
.feedback-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}
.doc-list::-webkit-scrollbar-thumb:hover,
.feedback-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Messages ── */
.message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 80%;
    animation: slideUp 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes slideUp {
    to { opacity: 1; transform: translateY(0); }
}

.message-content {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
}

.message-content p {
    margin-bottom: 0.75em;
}
.message-content p:last-child {
    margin-bottom: 0;
}

/* System Message */
.system-msg {
    align-self: center;
    max-width: 60%;
}
.system-msg .message-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.875rem;
}

/* User Message */
.user-msg {
    align-self: flex-end;
    align-items: flex-end;
}
.user-msg .message-content {
    background: hsl(0, 0%, 18%); /* ChatGPT user bubble gray (#2f2f2f) */
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
    box-shadow: none;
    border: 1px solid var(--border-color);
}

/* Bot Message */
.bot-msg {
    align-self: flex-start;
}
.bot-msg .message-content {
    background: transparent; /* Claude-style flat transparent message block */
    border: none;
    border-bottom-left-radius: 4px;
    box-shadow: none;
    padding-left: 0;
    padding-right: 0;
}

/* Message Meta (Latency/Confidence) */
.msg-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 0;
}

.citation-strip-wrap {
    width: 100%;
    margin-top: 10px;
}

.citation-strip {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border: none;
    background: transparent;
}

.citation-strip-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.citation-strip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.citation-card {
    text-align: left;
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.citation-card:hover {
    background: var(--bg-panel-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.citation-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.citation-card-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-primary);
    font-size: 0.72rem;
    font-weight: 700;
}

.citation-card-source {
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.citation-card-meta {
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.citation-card-snippet {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.meta-item.high-conf { color: var(--success); }
.meta-item.med-conf { color: var(--warning); }
.meta-item.low-conf { color: var(--error); }
.meta-item.cached { color: var(--accent-primary); }

/* Citations */
.citation-tag {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(87, 115, 255, 0.15);
    border: 1px solid rgba(87, 115, 255, 0.3);
    border-radius: 4px;
    color: var(--accent-primary);
    font-size: 0.75em;
    font-weight: 600;
    margin: 0 4px;
    cursor: pointer;
    vertical-align: super;
    transition: all 0.2s ease;
}

.citation-tag:hover {
    background: rgba(87, 115, 255, 0.3);
    transform: translateY(-1px);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ── Input Area ── */
.input-area {
    padding: 24px 40px 40px;
    background: linear-gradient(to top, var(--bg-main) 80%, transparent);
}

.input-container {
    display: flex;
    align-items: flex-end;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-panel);
}

.input-container:focus-within {
    border-color: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
}

#queryInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    padding: 8px;
    outline: none;
}

#queryInput::placeholder {
    color: var(--text-muted);
}

.mic-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.mic-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mic-btn.recording {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.12);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

.mic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.voice-status {
    color: var(--text-muted);
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.voice-status.idle {
    color: var(--text-muted);
}

.voice-status.recording {
    color: var(--warning);
}

.voice-status.recording::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--warning);
    animation: voice-blink 1s ease-in-out infinite;
}

.voice-status.processing {
    color: var(--accent-primary);
}

.voice-status.processing::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(0, 240, 255, 0.25);
    border-top-color: var(--accent-primary);
    animation: voice-spin 0.9s linear infinite;
}

.voice-status.error {
    color: var(--error);
}

.voice-status.success {
    color: var(--success);
}

@keyframes voice-spin {
    to { transform: rotate(360deg); }
}

@keyframes voice-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.send-btn {
    background: var(--accent-primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.send-btn:hover {
    background: hsl(160, 60%, 40%);
}

.send-btn:disabled {
    background: var(--bg-panel-hover);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.separator {
    color: var(--border-color);
}

/* ── Modal ── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.auth-modal {
    max-width: 420px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.auth-tab {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: var(--bg-panel-hover);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-field label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.auth-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.auth-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.auth-status {
    font-size: 0.8rem;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.auth-status.success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

/* Markdown-like formatting in messages */
.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-content ul, .message-content ol {
    margin-left: 20px;
    margin-bottom: 0.75em;
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

/* ── Feedback Audit Modal CSS ── */
.feedback-detail-modal {
    max-width: 800px;
    width: 95%;
}

.feedback-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.detail-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.detail-badge svg {
    color: var(--accent-primary);
}

.detail-badge.user-badge {
    border-color: var(--border-color);
}

.detail-badge.session-badge {
    border-color: var(--border-color);
    max-width: 280px;
    overflow: hidden;
}

.detail-badge.session-badge span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-badge.rating-badge {
    border-color: rgba(234, 179, 8, 0.2);
    color: #eab308;
    background: rgba(234, 179, 8, 0.03);
}

.detail-badge.escalation-badge {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: var(--error);
    font-weight: 600;
}

.feedback-detail-conversation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .feedback-detail-conversation {
        grid-template-columns: 1fr;
    }
}

.detail-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-panel h4 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-text-box {
    flex: 1;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 180px;
    overflow-y: auto;
}

.feedback-detail-chunks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.feedback-detail-chunks h4 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-chunk-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.detail-chunk-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.detail-chunk-item:hover {
    border-color: rgba(87, 115, 255, 0.25);
    background: rgba(87, 115, 255, 0.02);
}

.chunk-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.chunk-card-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chunk-card-score {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.chunk-card-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.mini-btn.inspect-fb-btn {
    color: var(--accent-primary);
    border-color: rgba(16, 185, 129, 0.2);
    background: rgba(16, 185, 129, 0.02);
}

.mini-btn.inspect-fb-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(16, 185, 129, 0.08);
}



/* Fluid Message Animation */
.message {
    opacity: 0;
    transform: translateY(16px);
    animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* FAQ Upload Toggle Switch style */
.faq-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
    transition: all 0.2s ease;
}

.faq-upload-label:hover {
    border-color: var(--accent-secondary);
    background: var(--bg-panel-hover);
    transform: translateY(-1px);
}

.faq-upload-label input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--accent-primary);
    width: 14px;
    height: 14px;
    margin: 0;
}


/* ── FAQ Manager Dashboard ── */
.faq-manager-modal .modal-body {
    display: flex;
    flex-direction: column;
    height: 70vh;
    max-height: 550px;
    padding: 20px;
    overflow: hidden;
}

.faq-manager-table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.25);
    margin-bottom: 16px;
}

.faq-manager-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.faq-manager-table th,
.faq-manager-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.5;
    vertical-align: top;
}

.faq-manager-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--border-color);
}

.faq-manager-table tbody tr {
    transition: background-color 0.2s ease;
}

.faq-manager-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.faq-manager-table td {
    color: var(--text-secondary);
}

.faq-manager-table .faq-question {
    font-weight: 500;
    color: var(--text-primary);
}

.faq-manager-table .faq-answer {
    color: var(--text-secondary);
    white-space: pre-line;
}

.faq-manager-table .faq-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

.faq-pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.faq-delete-btn {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    color: var(--error);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.faq-delete-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: var(--error);
    transform: scale(1.05);
}


/* ── PageIndex Explorer Modal ── */
.pageindex-modal {
    max-width: 860px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.pageindex-modal .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* Query bar (matched sections strip) */
.pageindex-query-bar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(139, 92, 246, 0.07);
    border-bottom: 1px solid rgba(139, 92, 246, 0.18);
    flex-shrink: 0;
}

.pageindex-query-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(265, 60%, 70%);
    white-space: nowrap;
    padding-top: 2px;
}

.pageindex-matched-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pi-match-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 6px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    color: var(--text-primary);
    animation: fadeSlideIn 0.25s ease;
}

.pi-chip-sim {
    font-weight: 700;
    color: hsl(265, 70%, 72%);
    font-size: 0.68rem;
    letter-spacing: 0.03em;
}

.pi-chip-title {
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pi-chip-page {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Tree area */
.pageindex-tree-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pageindex-tree-area::-webkit-scrollbar { width: 6px; }
.pageindex-tree-area::-webkit-scrollbar-track { background: transparent; }
.pageindex-tree-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}

.pageindex-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.pageindex-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.pageindex-empty small {
    font-size: 0.78rem;
    opacity: 0.7;
}

/* Document block */
.pi-doc-block {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.pi-doc-block:hover {
    border-color: rgba(139, 92, 246, 0.22);
}

.pi-doc-header {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
    cursor: default;
}

.pi-doc-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pi-doc-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.pi-doc-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pi-match-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: hsl(265, 70%, 75%);
    white-space: nowrap;
    animation: fadeSlideIn 0.3s ease;
}

.pi-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.pi-toggle-btn svg {
    transition: transform 0.25s ease;
}

.pi-toggle-btn:hover {
    border-color: var(--accent-secondary);
    color: var(--text-primary);
}

.pi-doc-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Node list */
.pi-node-list {
    list-style: none;
    padding: 6px 0;
    max-height: 340px;
    overflow-y: auto;
}

.pi-node-list::-webkit-scrollbar { width: 5px; }
.pi-node-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.09);
    border-radius: var(--radius-full);
}

.pi-node-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.035);
    transition: background 0.15s ease;
    position: relative;
}

.pi-node-item:last-child {
    border-bottom: none;
}

.pi-node-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pi-node-item.pi-node-matched {
    background: rgba(139, 92, 246, 0.08);
    border-left: 2px solid rgba(139, 92, 246, 0.6);
}

.pi-node-item.pi-node-matched:hover {
    background: rgba(139, 92, 246, 0.13);
}

.pi-node-empty {
    padding: 12px 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Bullet dot */
.pi-node-bullet {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.pi-node-bullet.matched {
    background: hsl(265, 70%, 65%);
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}

/* Node content */
.pi-node-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pi-node-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-node-matched .pi-node-title {
    color: hsl(265, 80%, 82%);
}

.pi-node-path {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-node-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 1.5px;
    margin-bottom: 1.5px;
    line-height: 1.35;
    white-space: normal;
}

.pi-node-page {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    font-style: italic;
}

.pi-node-sim {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: hsl(265, 70%, 78%);
    white-space: nowrap;
    flex-shrink: 0;
    animation: fadeSlideIn 0.25s ease;
}

/* ── Inline PageIndex button on bot messages ── */
.pi-inline-bar {
    margin-top: 8px;
}

.pi-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(139, 92, 246, 0.07);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
}

.pi-inline-btn:hover {
    background: rgba(139, 92, 246, 0.14);
    border-color: rgba(139, 92, 246, 0.5);
    color: var(--text-primary);
}

.pi-inline-btn strong {
    color: hsl(265, 70%, 78%);
}

.pi-inline-btn em {
    color: var(--text-primary);
    font-style: normal;
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.pi-inline-link {
    color: hsl(265, 60%, 70%);
    font-weight: 600;
    margin-left: 4px;
}

.pi-rebuild-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 4px;
    color: hsl(265, 65%, 75%);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto; /* align to the right before toggle */
    margin-right: 8px;
    transition: all 0.15s ease;
}

.pi-rebuild-doc-btn:hover {
    background: rgba(139, 92, 246, 0.16);
    border-color: rgba(139, 92, 246, 0.5);
    color: hsl(265, 75%, 82%);
}

.pi-rebuild-doc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
