/* Light theme defaults */
:root {
    /* Brand Colors */
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --primary-light: #3498db;
    --secondary: #e74c3c;
    --accent: #9b59b6;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;

    /* Neutrals */
    --light: #ecf0f1;
    --dark: #2c3e50;
    --gray: #95a5a6;
    --gray-light: #bdc3c7;
    --gray-dark: #204d50;

    /* Backgrounds */
    --bg-body: #f0f2f5;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-dark: #1a1d23;

    /* Panels & surfaces */
    --surface-bg: radial-gradient(circle at top left, rgba(255,255,255,0.16), rgba(255,255,255,0.05));
    --surface-border: rgba(255,255,255,0.25);
    --surface-shadow: 0 22px 45px rgba(0,0,0,0.35);

    /* Typography */
    --font-primary: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', monospace;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;

    /* Borders */
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --border-radius-xl: 18px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.16);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.28);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Table */
    --table-header-bg: #f1f3f5;
    --table-row-even: #f8f9fb;
    --table-row-hover: #eaf2ff;
}

/* Dark theme overrides */
body[data-theme="dark"] {
    --bg-body: #05070b;
    --bg-primary: rgba(5, 7, 11, 0.96);
    --bg-secondary: rgba(18, 24, 38, 0.95);
    --light: #f4f6fb;
    --dark: #dfe6f0;
    --gray: #a0aec0;
    --gray-light: #0f367a;
    --gray-dark: #3c4e67;

    --surface-bg: radial-gradient(circle at top left, rgba(255,255,255,0.08), rgba(10, 15, 25, 0.95));
    --surface-border: rgba(255,255,255,0.12);
    --surface-shadow: 0 22px 45px rgba(0,0,0,0.8);

    --table-header-bg: #131927;
    --table-row-even: rgba(20, 26, 40, 0.95);
    --table-row-hover: rgba(39, 60, 117, 0.7);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

/* =========================================================
   Typography
   ========================================================= */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-md);
    color: var(--primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] h4 {
    color: #e2e8f0;
}

p {
    margin-bottom: var(--spacing-md);
}

/* =========================================================
   Header
   ========================================================= */

/* ===== HEADER / TOP BAR ================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: linear-gradient(135deg, #3f4c5c, #364352 40%, #2e3a48 100%);
    color: white;
    padding: var(--spacing-md) var(--spacing-xl);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* Brand / logo text */
.logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-width: 0;
}

.logo-dot {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #ffe9a0, #ffb000 60%, #d88900 100%);
    box-shadow: 0 0 12px rgba(255, 191, 0, 0.9);
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.logo-title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
}

.logo-subtitle {
    font-size: 0.78rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    opacity: 0.78;
    white-space: nowrap;
}

.version-pill {
    margin-left: var(--spacing-sm);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.75rem;
    opacity: 0.9;
    background: radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.25), transparent 55%);
}

/* Header actions (right side) */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Header button base (reuses existing .btn but tweaks for top bar) */
.btn-header-outline,
.btn-header-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    border-width: 1px;
    border-style: solid;
    font-size: 0.9rem;
    font-weight: 500;
    background: transparent;
    color: #f5f7fb;
    box-shadow: none;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-header-outline {
    border-color: rgba(255, 255, 255, 0.65);
    background: linear-gradient(
        135deg,
        rgba(6, 34, 60, 0.6),
        rgba(23, 73, 122, 0.4)
    );
    backdrop-filter: blur(10px);
}

.btn-header-outline:hover {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.12),
        rgba(255, 255, 255, 0.02)
    );
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.btn-header-primary {
    border-color: transparent;
    background: radial-gradient(circle at 0 0, #68b5ff 0, #0b8df5 45%, #0066ff 100%);
    box-shadow: 0 10px 24px rgba(0, 102, 255, 0.5);
}

.btn-header-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(0, 102, 255, 0.65);
}

/* ===== THEME TOGGLE ====================================================== */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.9rem 0.25rem 0.25rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.2), transparent 55%);
    cursor: pointer;
    color: #fefefe;
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
    border-color: rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
    transform: translateY(-1px);
}

.theme-knob {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 30%, #ffeaa7, #fbc531 55%, #e1a200 100%);
    color: #7b4d00;
    box-shadow: 0 0 10px rgba(251, 197, 49, 0.9);
}

.theme-label {
    padding-right: 0.25rem;
}

/* Icon switch when dark mode is active */
[data-theme="dark"] .theme-knob {
    background: radial-gradient(circle at 30% 25%, #ffffff, #9c88ff 45%, #3b1fb4 100%);
    color: #f5f6fa;
    box-shadow: 0 0 12px rgba(156, 136, 255, 0.9);
}

/* Make header look good on small screens */
@media (max-width: 768px) {
    .app-header {
        padding-inline: var(--spacing-md);
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

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


.header-content {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

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

.logo-section i {
    font-size: 2rem;
    padding: 8px;
    border-radius: 16px;
    background: radial-gradient(circle at 30% 20%, #f1c40f, #e67e22);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.logo-section h1 {
    color: #ecf0f1;
    margin-bottom: 0;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
}

.version {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.22);
}

/* Theme Toggle (mini switch in header) */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.18);
    color: #ecf0f1;
    font-size: 0.75rem;
    cursor: pointer;
    backdrop-filter: blur(12px);
}

.theme-toggle-knob {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #f1c40f;
    box-shadow: 0 0 6px rgba(241,196,15,0.9);
    position: relative;
    overflow: hidden;
}

body[data-theme="dark"] .theme-toggle-knob {
    background: #3498db;
    box-shadow: 0 0 8px rgba(52,152,219,0.9);
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.main-content {
    flex: 1;
    padding: var(--spacing-xl);
    max-width: 1320px;
    margin: 2rem auto 3rem auto;
    width: 100%;
}

/* Utility */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.hidden { display: none; }
.visible { display: block; }

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--gray-light);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gray);
}

/* Selection */
::selection {
    background-color: var(--primary-light);
    color: white;
}

/* Focus */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* =========================================================
   Shared Surface / Card Styles
   ========================================================= */

.surface {
    background: var(--surface-bg);
    border-radius: var(--border-radius-xl);
    border: 1px solid var(--surface-border);
    box-shadow: var(--surface-shadow);
    backdrop-filter: blur(20px);
}

.card,
.analysis-controls,
.results-section {
    background: transparent;
    border-radius: var(--border-radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: none;
}

/* =========================================================
   Stats Dashboard
   ========================================================= */

.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    position: relative;
    padding: var(--spacing-lg);
    border-radius: 16px;
    background: radial-gradient(circle at top left, rgba(255,255,255,0.25), rgba(44,62,80,0.9));
    box-shadow: 0 16px 35px rgba(0,0,0,0.4);
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: #ecf0f1;
}

body[data-theme="dark"] .stat-card {
    background: radial-gradient(circle at top left, rgba(255,255,255,0.08), rgba(10, 14, 23, 0.98));
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent 55%);
    pointer-events: none;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: rgba(0,0,0,0.35);
    box-shadow: 0 10px 24px rgba(0,0,0,0.45);
    z-index: 1;
}

.stat-icon i {
    color: #f1c40f;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.1;
    z-index: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: rgba(236, 240, 241, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    z-index: 1;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.55rem 1.4rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn i {
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.7rem 1.8rem;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 8px 20px rgba(41, 128, 185, 0.55);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(41, 128, 185, 0.7);
}

.btn-secondary {
    background: rgba(255,255,255,0.06);
    color: #ecf0f1;
    border-color: rgba(255,255,255,0.3);
    backdrop-filter: blur(14px);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.16);
}

.btn-outline {
    background: transparent;
    color: #ecf0f1;
    border-color: rgba(255,255,255,0.4);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 8px 20px rgba(192, 57, 43, 0.55);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* =========================================================
   Input Section
   ========================================================= */

.input-methods {
    display: flex;
    gap: var(--spacing-sm);
    background: rgba(255,255,255,0.2);
    padding: var(--spacing-sm);
    border-radius: 999px;
}

body[data-theme="dark"] .input-methods {
    background: rgba(0,0,0,0.3);
}

.method-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    background: transparent;
    color: var(--gray-dark);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    font-weight: 500;
}

.method-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

body[data-theme="dark"] .method-btn.active {
    background: #1a202c;
    color: #edf2f7;
}

.method-btn:hover:not(.active) {
    background: rgba(255,255,255,0.3);
    color: var(--primary-dark);
}

.input-panel {
    display: none;
}

.input-panel.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.text-input-container {
    position: relative;
}

#textInput {
    width: 100%;
    min-height: 200px;
    padding: var(--spacing-lg);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background 0.25s ease;
    background: #ffffff;
}

body[data-theme="dark"] #textInput {
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    border-color: #2d3748;
}

#textInput:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.text-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* Upload Zone */
.upload-zone {
    border: 3px dashed var(--gray-light);
    border-radius: var(--border-radius-xl);
    padding: var(--spacing-xxl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    background: #ffffff;
}

body[data-theme="dark"] .upload-zone {
    background: rgba(12, 18, 30, 0.96);
    border-color: #4a5568;
}

.upload-zone:hover {
    border-color: var(--primary-light);
    background-color: rgba(52, 152, 219, 0.05);
}

.upload-zone.dragover {
    border-color: var(--primary);
    background-color: rgba(52, 152, 219, 0.1);
}

.upload-content i {
    font-size: 3rem;
    color: var(--gray);
    margin-bottom: var(--spacing-md);
}

.upload-content h3 {
    margin-bottom: var(--spacing-sm);
    color: var(--primary);
}

.file-types {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    flex-wrap: wrap;
}

.file-type-tag {
    background: var(--gray-light);
    color: var(--dark);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

#fileInput {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.uploaded-files {
    margin-top: var(--spacing-lg);
}

.uploaded-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--shadow-sm);
}

/* URL Input */
.url-input-container {
    max-width: 600px;
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

#urlInput {
    flex: 1;
    padding: var(--spacing-md);
    border: 2px solid var(--gray-light);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background 0.25s ease;
    background: #ffffff;
}

body[data-theme="dark"] #urlInput {
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
    border-color: #2d3748;
}

#urlInput:focus {
    border-color: var(--primary-light);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.url-options {
    display: flex;
    gap: var(--spacing-lg);
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--gray-dark);
}

/* =========================================================
   Analysis Controls
   ========================================================= */

.analysis-controls.surface {
    padding: var(--spacing-xl);
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.control-group h3 {
    color: var(--primary);
    margin-bottom: var(--spacing-md);
    font-size: 1.1rem;
}

body[data-theme="dark"] .control-group h3 {
    color: #edf2f7;
}

.control-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}

.control-item:hover {
    background-color: rgba(255,255,255,0.05);
}

.control-item label {
    cursor: pointer;
    flex: 1;
}

.control-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.control-item input[type="number"],
.control-item input[type="range"],
.control-item select {
    padding: var(--spacing-sm);
    border: 1px solid var(--gray-light);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
}

.control-item input[type="range"] {
    flex: 1;
}

.analysis-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--gray-light);
}

/* =========================================================
   Results Section & Tabs
   ========================================================= */

.results-section.surface {
    padding: var(--spacing-xl);
}

.results-tabs {
    display: inline-flex;
    gap: 0;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 4px;
    border: 1px solid rgba(255,255,255,0.2);
}

body[data-theme="dark"] .results-tabs {
    background: rgba(15,23,42,0.8);
    border-color: rgba(148,163,184,0.4);
}

.result-tab {
    padding: 0.55rem 1.3rem;
    border-radius: 999px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: rgba(44, 62, 80, 0.7);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    position: relative;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

body[data-theme="dark"] .result-tab {
    color: rgba(226,232,240,0.7);
}

.result-tab i {
    font-size: 0.95rem;
}

.result-tab.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

body[data-theme="dark"] .result-tab.active {
    background: #111827;
    color: #e5e7eb;
}

.result-tab.active::after {
    content: '';
    position: absolute;
    inset: auto 14px -3px 14px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, #3498db, #9b59b6);
}

.result-tab:hover:not(.active) {
    background: rgba(255,255,255,0.28);
    color: var(--primary-dark);
}

body[data-theme="dark"] .result-tab:hover:not(.active) {
    background: rgba(31,41,55,0.85);
}

.results-content {
    min-height: 500px;
    padding: var(--spacing-xl);
    background: #ffffff;
    border-radius: 16px;
    margin-top: var(--spacing-md);
}

body[data-theme="dark"] .results-content {
    background: rgba(10, 14, 24, 0.97);
    color: #e5e7eb;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    text-align: center;
}

.welcome-content {
    max-width: 640px;
    margin: 0 auto;
}

.welcome-content i {
    font-size: 3.5rem;
    color: #f1c40f;
    margin-bottom: var(--spacing-lg);
    filter: drop-shadow(0 10px 22px rgba(0,0,0,0.4));
}

.welcome-content h3 {
    color: var(--primary);
    margin-bottom: var(--spacing-md);
    font-size: 1.7rem;
}

.feature-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    max-width: 600px;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-md);
    background: rgba(255,255,255,0.08);
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.25);
    backdrop-filter: blur(18px);
}

.feature i {
    font-size: 1.5rem;
    color: var(--primary);
}

/* =========================================================
   Result Visualisations
   ========================================================= */

/* Word Frequency */
.word-frequency-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.frequency-item {
    display: grid;
    grid-template-columns: 40px minmax(80px, 1fr) 80px;
    align-items: center;
    gap: var(--spacing-sm);
}

.frequency-item .rank {
    font-weight: 700;
    color: var(--gray-dark);
}

.frequency-item .word {
    font-weight: 500;
}

.frequency-item .count {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--gray-dark);
}

.frequency-bar {
    grid-column: 2 / 4;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    margin-top: 4px;
}

/* Concordance */
.concordance-results {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.concordance-line {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--spacing-sm);
    padding: 4px 0;
    border-bottom: 1px dashed var(--gray-light);
}

.concordance-line .left-context {
    text-align: right;
    color: var(--gray-dark);
    padding-right: var(--spacing-sm);
}

.concordance-line .keyword {
    font-weight: 700;
    color: var(--secondary);
}

.concordance-line .right-context {
    text-align: left;
    color: var(--gray-dark);
    padding-left: var(--spacing-sm);
}

/* Collocations */
.collocations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.collocation-card {
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
}

.topic-card h4,
.collocation-card h4 {
    margin-bottom: var(--spacing-sm);
}

.collocation-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    font-size: 0.9rem;
}

.collocation-list li {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

/* NER */
.ner-results h4 {
    margin-top: var(--spacing-md);
}

.ner-entities {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.entity-tag {
    font-size: 0.8rem;
    padding: 0.15rem 0.4rem;
    border-radius: 999px;
    background: var(--gray-light);
    color: var(--dark);
}

.entity-tag.person {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
}
.entity-tag.organization {
    background: rgba(52, 152, 219, 0.15);
    color: #2980b9;
}
.entity-tag.location {
    background: rgba(46, 204, 113, 0.15);
    color: #27ae60;
}
.entity-tag.date {
    background: rgba(241, 196, 15, 0.2);
    color: #d35400;
}
.entity-tag.other {
    background: rgba(155, 89, 182, 0.18);
    color: #8e44ad;
}

/* =========================================================
   Tables – zebra + sticky header
   ========================================================= */

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}

/* POS */
.pos-table th,
.pos-table td,
.keyword-table th,
.keyword-table td,
.sentiment-table th,
.sentiment-table td {
    border: 1px solid var(--gray-light);
    padding: 6px 8px;
}

/* sticky header */
.pos-table thead th,
.keyword-table thead th,
.sentiment-table thead th {
    background: var(--table-header-bg);
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
}

/* zebra rows */
.pos-table tbody tr:nth-child(even),
.keyword-table tbody tr:nth-child(even),
.sentiment-table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}

.pos-table tbody tr:hover,
.keyword-table tbody tr:hover,
.sentiment-table tbody tr:hover {
    background-color: var(--table-row-hover);
}

/* Sentiment */
.sentiment-overall {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--border-radius);
    background: var(--bg-secondary);
}

.sentiment-score-positive {
    color: var(--success);
    font-weight: 700;
}
.sentiment-score-negative {
    color: var(--danger);
    font-weight: 700;
}
.sentiment-score-neutral {
    color: var(--gray-dark);
    font-weight: 700;
}

/* Topics */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md);
}

.topic-card {
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-light);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
}

.topic-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.85rem;
}

.topic-keywords span {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 999px;
}

/* Keyword list table already covered above */

/* =========================================================
   Loading Overlay + Animated Progress Bar
   ========================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: var(--bg-primary);
    padding: var(--spacing-xxl);
    border-radius: var(--border-radius-xl);
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--gray-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-lg);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-light);
    border-radius: 4px;
    margin: var(--spacing-lg) 0;
    overflow: hidden;
    position: relative;
}

/* Animated shimmer while active */
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    transition: width 0.3s ease;
}

/* Animate a moving highlight */
.loading-overlay.active .progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        120deg,
        transparent 0%,
        rgba(255,255,255,0.6) 25%,
        transparent 50%
    );
    animation: progress-shimmer 1.3s infinite;
    mix-blend-mode: screen;
}

.loading-stats {
    color: var(--gray-dark);
    font-size: 0.9rem;
}

/* =========================================================
   Modal
   ========================================================= */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

/* Dark mode tweak */
body[data-theme="dark"] .modal {
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--border-radius-xl);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal .modal-content {
    backdrop-filter: none !important;
}

/* === MODAL HEADER CLOSE BUTTON === */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--gray-dark);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] .modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .modal-close {
  color: #e5e7eb;
}

/* =========================================================
   Settings Form
   ========================================================= */

.settings-group {
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.settings-group label {
    font-weight: 500;
}

.settings-group input {
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--gray-light);
    font-family: inherit;
}

.settings-group small {
    font-size: 0.8rem;
    color: var(--gray-dark);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

/* =========================================================
   Animations
   ========================================================= */

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-md);
        margin-top: 1.5rem;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: var(--spacing-sm);
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
}

/* =========================================================
   Print
   ========================================================= */

@media print {
    .no-print {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-light);
    }

    .app-header,
    .analysis-controls,
    .results-tabs,
    .loading-overlay,
    .modal {
        display: none !important;
    }
}

/* Progress bar animation while analyzing */
.loading-overlay.active .progress-fill {
    animation: progressPulse 1.2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%   { width: 10%; opacity: 0.6; }
    50%  { width: 75%; opacity: 1; }
    100% { width: 40%; opacity: 0.8; }
}

/* Zebra + sticky header for all result tables */
.pos-table,
.keyword-table,
.sentiment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.pos-table th,
.keyword-table th,
.sentiment-table th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.pos-table tbody tr:nth-child(even),
.keyword-table tbody tr:nth-child(even),
.sentiment-table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .pos-table tbody tr:nth-child(even),
[data-theme="dark"] .keyword-table tbody tr:nth-child(even),
[data-theme="dark"] .sentiment-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

/* Icon-only header buttons */
.btn-icon-only {
    padding: 0.5rem 0.7rem;
    min-width: 40px;
    justify-content: center;
}

.btn-icon-only i {
    font-size: 1rem;
}

#settingsBtn {
    padding: 0.4rem 0.6rem;
    width: 40px;
    justify-content: center;
}

#settingsBtn span {
    display: none;
}

#themeToggle {
    padding: 0.25rem;
    gap: 0;              /* no extra space */
}

#themeToggle .theme-label {
    display: none;
}

/* Make the moon icon knob nice and round */
.theme-knob {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Just to be safe, ensure icons are visible */
#settingsBtn i,
#themeToggle i {
    color: #ffffff;
    font-size: 1rem;
}

/* Simple circular icon buttons in header */
.icon-btn {
    width: 34px;
    height: 34px;
    margin-left: 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: #ffffff;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

body[data-theme="dark"] .icon-btn {
    border-color: rgba(255, 255, 255, 0.35);
}

/* Logo container inside header actions */
.logo-link {
    display: flex;
    align-items: center;
    margin-right: 12px;   /* space before Export button */
}

/* Logo image */
.talos-logo {
    height: 50px;     
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Hover effect */
.talos-logo:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Footer */
.app-footer {
    width: 100%;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;

    /* background: linear-gradient(135deg, #3f4c5c, #364352 40%, #2e3a48 100%); */
    color: #34648f;

    font-size: 0.9rem;
    letter-spacing: 0.03em;

    /* border-top: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 -10px 22px rgba(0,0,0,0.25); */
}

.app-footer p {
    margin: 0;
    opacity: 0.85;
}

.app-footer a {
    color: #34648f;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.app-footer a:hover {
    opacity: 0.7;
}

/* =========================================================
   Pattern Extraction Modal
   ========================================================= */

.pattern-builder {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: var(--spacing-lg);
  margin-top: var(--spacing-md);
}

@media (max-width: 900px) {
  .pattern-builder { grid-template-columns: 1fr; }
}

.pattern-positions {
  border: 1px solid var(--gray-light);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  background: var(--bg-secondary);
}

body[data-theme="dark"] .pattern-positions {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148,163,184,0.35);
}

.pattern-row {
  display: grid;
  grid-template-columns: 160px 140px 1fr;
  gap: var(--spacing-sm);
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--gray-light);
}

body[data-theme="dark"] .pattern-row {
  border-bottom-color: rgba(148,163,184,0.25);
}

.pattern-row:last-child {
  border-bottom: none;
}

.pattern-check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  color: var(--dark);
}

body[data-theme="dark"] .pattern-check {
  color: var(--light);
}

.pattern-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.pattern-select {
  padding: var(--spacing-sm);
  border: 1px solid var(--gray-light);
  border-radius: var(--border-radius-sm);
  background: var(--bg-primary);
  color: var(--dark);
}

body[data-theme="dark"] .pattern-select {
  background: rgba(5, 7, 11, 0.96);
  color: #e2e8f0;
  border-color: rgba(148,163,184,0.35);
}

.pattern-hint {
  color: var(--gray-dark);
  font-size: 0.85rem;
  opacity: 0.9;
}

.pattern-examples {
  border: 1px solid var(--gray-light);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-md);
  background: radial-gradient(circle at top left, rgba(255,255,255,0.25), rgba(44,62,80,0.08));
}

body[data-theme="dark"] .pattern-examples {
  border-color: rgba(148,163,184,0.35);
  background: radial-gradient(circle at top left, rgba(255,255,255,0.08), rgba(10, 14, 23, 0.6));
}

.pattern-examples-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  margin-bottom: .6rem;
}

.pattern-examples-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--gray-dark);
  font-size: 0.9rem;
}

.pattern-examples-list code {
  background: rgba(255,255,255,0.25);
  padding: 0.1rem 0.4rem;
  border-radius: 8px;
}

body[data-theme="dark"] .pattern-examples-list code {
  background: rgba(0,0,0,0.35);
  color: #e2e8f0;
}

.pattern-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: flex-end;
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--gray-light);
}

body[data-theme="dark"] .pattern-actions {
  border-top-color: rgba(148,163,184,0.25);
}

.pattern-output {
  margin-top: var(--spacing-lg);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--gray-light);
  padding: var(--spacing-md);
  background: var(--bg-secondary);
}

body[data-theme="dark"] .pattern-output {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(148,163,184,0.35);
}

.pattern-match {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: .45rem .55rem;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.55);
  margin-top: .5rem;
}

body[data-theme="dark"] .pattern-match {
  background: rgba(0,0,0,0.25);
  border-color: rgba(148,163,184,0.18);
}

.pattern-match .phrase {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.pattern-match .meta {
  color: var(--gray-dark);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Background with papyrus + overlay */
body {
    font-family: var(--font-primary);
    background-image: url('../images/background_papyri.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top, rgba(0,0,0,0.25) 0, transparent 55%),
        linear-gradient(to bottom, rgba(0,0,0,0.35), rgba(0,0,0,0.18));
    z-index: -1;
}

body[data-theme="dark"]::before {
    background:
        radial-gradient(circle at top, rgba(0,0,0,0.7) 0, transparent 55%),
        linear-gradient(to bottom, rgba(0,0,0,0.92), rgba(0,0,0,0.8));
}

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