/* ================================================
   Document Intelligence Platform - Main Styles
   Modern dark theme with glassmorphism effects
   ================================================ */

:root {
    /* Color Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-elevated: #22222f;

    --surface-glass: rgba(255, 255, 255, 0.03);
    --surface-glass-hover: rgba(255, 255, 255, 0.06);
    --surface-glass-active: rgba(255, 255, 255, 0.08);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);

    --text-primary: #f0f0f5;
    --text-secondary: #9898a8;
    --text-tertiary: #6a6a78;
    --text-muted: #4a4a58;

    --accent-primary: #7c5cff;
    --accent-primary-hover: #9077ff;
    --accent-primary-glow: rgba(124, 92, 255, 0.3);

    --accent-success: #3dd68c;
    --accent-success-glow: rgba(61, 214, 140, 0.3);

    --accent-warning: #ffb347;
    --accent-warning-glow: rgba(255, 179, 71, 0.3);

    --accent-error: #ff5c7c;
    --accent-error-glow: rgba(255, 92, 124, 0.3);

    --accent-info: #5cb8ff;
    --accent-info-glow: rgba(92, 184, 255, 0.3);

    /* Semantic colors for bounding boxes */
    --box-title: rgba(124, 92, 255, 0.4);
    --box-paragraph: rgba(92, 184, 255, 0.25);
    --box-table: rgba(61, 214, 140, 0.3);
    --box-list: rgba(255, 179, 71, 0.3);
    --box-default: rgba(255, 255, 255, 0.2);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-primary-glow);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Layout */
    --top-nav-height: 56px;
    --comparison-width: 400px;
    --header-height: 60px;

    /* Standardized Component Sizes */
    --btn-sm-padding: 4px 10px;
    --btn-sm-font: 0.7rem;
    --btn-sm-icon: 14px;
    --btn-icon-size: 28px;
    --btn-icon-inner: 14px;
    --badge-font: 0.65rem;
    --badge-dot: 5px;
    --badge-padding: 2px 8px;
    --tab-padding: 6px 12px;
    --tab-font: 0.75rem;
    --tab-icon: 14px;
}

/* ================================================
   Login Screen
   ================================================ */

.login-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-screen.hidden {
    display: none;
}

.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-2xl);
    background: var(--surface-glass);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    width: 56px;
    height: 56px;
    color: var(--accent-primary);
}

.login-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin: 0;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: var(--spacing-md);
    padding: 10px 24px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.login-btn:hover {
    background: var(--accent-primary-hover);
}

/* ================================================
   Reset & Base
   ================================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* ================================================
   App Layout
   ================================================ */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ================================================
   Top Menu Bar
   ================================================ */

.top-menu-bar {
    height: var(--top-nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
    gap: var(--spacing-lg);
    flex-shrink: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

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

.logo h1 {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-tabs {
    display: flex;
    gap: var(--spacing-xs);
    flex: 1;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.nav-tab:hover {
    background: var(--surface-glass);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
}

.auth-area {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

.auth-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-glass);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.auth-btn:hover {
    background: var(--surface-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.sign-out-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
    color: var(--text-tertiary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-name {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================================================
   Buttons
   ================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

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

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-primary), #6347d9);
    color: white;
    box-shadow: var(--shadow-sm), 0 0 20px var(--accent-primary-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-primary-hover), var(--accent-primary));
    transform: translateY(-1px);
    box-shadow: var(--shadow-md), 0 0 30px var(--accent-primary-glow);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--surface-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--surface-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-glass); color: var(--text-primary); }

.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ================================================
   Main Content
   ================================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* ================================================
   Comparison Dialog
   ================================================ */

.comparison-dialog {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.comparison-dialog.active { display: flex; }

.comparison-dialog>* {
    width: 400px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* ================================================
   Toast Notifications
   ================================================ */

.toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease, toastFadeOut 0.3s ease 3s forwards;
}

.toast.success { border-color: var(--accent-success); }
.toast.error { border-color: var(--accent-error); }
.toast.warning { border-color: var(--accent-warning); }
.toast.info { border-color: var(--accent-info); }

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

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* ================================================
   Scrollbars
   ================================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ================================================
   Utility Classes
   ================================================ */

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--accent-success); }
.text-error { color: var(--accent-error); }
.text-warning { color: var(--accent-warning); }

/* ================================================
   Loading States
   ================================================ */

.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--surface-glass) 25%, var(--surface-glass-hover) 50%, var(--surface-glass) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================================
   Empty State
   ================================================ */

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: var(--spacing-2xl); text-align: center; color: var(--text-muted);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: var(--spacing-lg); opacity: 0.5; }
.empty-state p { max-width: 280px; line-height: 1.5; }

/* ================================================
   Status Badges
   ================================================ */

.status-badge {
    display: inline-flex; align-items: center; gap: var(--spacing-xs);
    padding: 2px 8px; font-size: 0.75rem; font-weight: 500;
    border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.02em;
}

.status-badge.uploading { background: var(--accent-warning-glow); color: var(--accent-warning); }
.status-badge.parsed { background: var(--accent-success-glow); color: var(--accent-success); }
.status-badge.error { background: var(--accent-error-glow); color: var(--accent-error); }

.status-badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

.status-badge.uploading::before { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ================================================
   Graph Files Modal
   ================================================ */

.graph-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; animation: fadeIn 0.2s ease;
}

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

.graph-modal {
    width: 480px; max-height: 70vh;
    background: var(--bg-secondary); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
    animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.graph-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg); border-bottom: 1px solid var(--border-subtle);
}

.graph-modal-title {
    display: flex; align-items: center; gap: var(--spacing-sm);
    font-size: 0.95rem; font-weight: 600; color: var(--text-primary);
}

.graph-modal-close { color: var(--text-tertiary); cursor: pointer; }
.graph-modal-close:hover { color: var(--text-primary); }

.graph-modal-body { flex: 1; overflow-y: auto; padding: var(--spacing-md) 0; }

.graph-modal-loading, .graph-modal-empty, .graph-modal-error {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: var(--spacing-2xl) var(--spacing-lg); gap: var(--spacing-md);
    color: var(--text-muted); text-align: center;
}

.graph-modal-error p { color: var(--accent-error); font-size: 0.85rem; }

.graph-file-count {
    padding: 0 var(--spacing-lg) var(--spacing-sm);
    font-size: 0.75rem; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.03em;
}

.graph-file-list { display: flex; flex-direction: column; }

.graph-file-row {
    display: flex; align-items: center; gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg); cursor: default;
    transition: background var(--transition-fast);
}

.graph-file-row:hover { background: var(--surface-glass-hover); }

.graph-file-icon {
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; background: var(--surface-glass); border-radius: var(--radius-sm);
}

.graph-file-info {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
}

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

.graph-file-meta { font-size: 0.7rem; color: var(--text-tertiary); }

.graph-file-link {
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    color: var(--text-tertiary); transition: all var(--transition-fast);
}

.graph-file-link:hover { background: var(--surface-glass); color: var(--accent-info); }
