/* 
* Premium Dark Mode UI for Course RAG 
* Uses glassmorphism, dynamic gradients, and modern typography
*/

:root {
    --bg-base: #09090b;
    --bg-surface: rgba(24, 24, 27, 0.6);
    --bg-surface-hover: rgba(39, 39, 42, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-color: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent-color: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --backdrop-blur: blur(12px);
    
    --font-heading: 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ═══════════════════════════════════════ */
/* Animated Background                     */
/* ═══════════════════════════════════════ */

.bg-gradient {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, var(--primary-glow) 0%, transparent 20%),
                radial-gradient(circle at 80% 20%, var(--accent-glow) 0%, transparent 20%);
    opacity: 0.15;
    z-index: -2;
    animation: rotateBg 30s linear infinite;
    pointer-events: none;
}

.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
    pointer-events: none;
    mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
    -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 80%);
}

@keyframes rotateBg {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════ */
/* App Layout                              */
/* ═══════════════════════════════════════ */

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: flex;
    flex-direction: column;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

#app-screen {
    max-width: 1200px;
    margin: 0 auto;
    height: 95vh;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    box-shadow: var(--shadow-glass);
    overflow: hidden;
}

/* ═══════════════════════════════════════ */
/* Login Screen                            */
/* ═══════════════════════════════════════ */

#login-screen {
    align-items: center;
    justify-content: center;
}

.login-container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.login-glow {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    filter: blur(40px);
    opacity: 0.3;
    z-index: -1;
    border-radius: 50%;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    box-shadow: var(--shadow-glass);
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--primary-color);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-body);
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-primary svg {
    width: 18px;
    height: 18px;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    height: 16px;
}

/* ═══════════════════════════════════════ */
/* Navigation                              */
/* ═══════════════════════════════════════ */

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    min-height: 64px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(24, 24, 27, 0.4);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
}

.nav-icon {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.nav-tabs {
    display: flex;
    gap: 8px;
    height: 100%;
    align-items: center;
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    height: 40px;
}

.nav-tab svg {
    width: 16px;
    height: 16px;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.nav-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}

.nav-logout:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.nav-logout svg {
    width: 20px;
    height: 20px;
}

/* ═══════════════════════════════════════ */
/* Panels                                  */
/* ═══════════════════════════════════════ */

.panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.panel.active {
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════ */
/* Chat Interface                          */
/* ═══════════════════════════════════════ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

/* Hide scrollbar but keep functionality */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.message.human {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 14px 20px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.6;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.message.human .message-bubble {
    background: linear-gradient(135deg, var(--primary-color), #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: rgba(30, 30, 34, 0.8);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.message.human .message-meta {
    align-self: flex-end;
}

.role-badge {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.provider-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.query-type-badge {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-color);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(24, 24, 27, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    align-self: flex-start;
    animation: fadeIn 0.3s ease;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* Chat Input */
.chat-input-area {
    padding: 24px 32px;
    border-top: 1px solid var(--border-color);
    background: rgba(24, 24, 27, 0.4);
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary-color);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 12px 16px;
    font-size: 15px;
    font-family: var(--font-body);
    resize: none;
    max-height: 200px;
    line-height: 1.5;
}

#chat-input:focus {
    outline: none;
}

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

.btn-send:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-send:not(:disabled):hover {
    background: #2563eb;
    transform: scale(1.05);
}

.btn-send svg {
    width: 20px;
    height: 20px;
}

.chat-disclaimer {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

.welcome-message {
    align-self: center;
    text-align: center;
    margin: auto 0;
    max-width: 600px;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 32px;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 100px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* ═══════════════════════════════════════ */
/* Upload Panel                            */
/* ═══════════════════════════════════════ */

.upload-container, .admin-container {
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin: 0 auto 16px;
    transition: color 0.3s;
}

.drop-zone:hover .drop-icon {
    color: var(--primary-color);
}

.drop-text {
    font-size: 18px;
    font-weight: 500;
}

.drop-subtext {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
}

.divider-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 32px 0;
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.divider-text::before, .divider-text::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider-text span {
    padding: 0 16px;
}

.drive-link-input {
    display: flex;
    gap: 12px;
}

.drive-link-input input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

.hidden {
    display: none !important;
}

.upload-status {
    margin-top: 32px;
}

.upload-status-card, .approval-card {
    background: rgba(24, 24, 27, 0.8);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.1);
}

.upload-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.upload-status-card p {
    text-align: center;
    font-weight: 500;
}

.approval-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* ═══════════════════════════════════════ */
/* Admin Panel                             */
/* ═══════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.action-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
}

.action-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.action-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.action-controls {
    display: flex;
    gap: 12px;
}

.action-controls select {
    flex: 1;
    background: rgba(24, 24, 27, 0.8);
    border: 1px solid var(--border-color);
    color: white;
    border-radius: var(--radius-md);
    padding: 0 12px;
}

.progress-bar {
    height: 24px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-sm);
    margin-top: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    width: 0%;
    transition: width 0.3s;
}

.progress-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.config-section h3 {
    font-size: 18px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.config-item {
    font-size: 14px;
}

.config-key {
    color: var(--text-muted);
}

.config-val {
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* ═══════════════════════════════════════ */
/* Markdown Overrides                      */
/* ═══════════════════════════════════════ */

.message-bubble h1, 
.message-bubble h2, 
.message-bubble h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.message-bubble blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 12px;
    margin: 12px 0;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-bubble code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 4px;
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.message-bubble th, .message-bubble td {
    padding: 10px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.message-bubble th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.message-bubble details {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-top: 16px;
}

.message-bubble summary {
    cursor: pointer;
    font-weight: 500;
    outline: none;
}

.message-bubble a {
    color: #60a5fa;
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9999;
}

.toast {
    background: var(--bg-surface-hover);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--border-color);
    color: white;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.error { border-left: 4px solid var(--danger); }
.toast.success { border-left: 4px solid var(--success); }
.toast.info { border-left: 4px solid var(--primary-color); }
