/* ========================================================================
   CSS Custom Properties - Theme System
   ======================================================================== */

:root {
    /* Primary Colors - Deep Academic Green */
    --primary-50: #ecfdf5;
    --primary-100: #d1fae5;
    --primary-200: #a7f3d0;
    --primary-300: #6ee7b7;
    --primary-400: #34d399;
    --primary-500: #10b981;
    --primary-600: #059669;
    --primary-700: #047857;
    --primary-800: #065f46;
    --primary-900: #064e3b;

    /* Neutral Colors */
    --neutral-50: #fafafa;
    --neutral-100: #f5f5f5;
    --neutral-200: #e5e5e5;
    --neutral-300: #d4d4d4;
    --neutral-400: #a3a3a3;
    --neutral-500: #737373;
    --neutral-600: #525252;
    --neutral-700: #404040;
    --neutral-800: #262626;
    --neutral-900: #171717;

    /* Accent Colors */
    --accent-gold: #d4a574;
    --accent-amber: #f59e0b;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-rose: #f43f5e;

    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Light Theme (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-header: linear-gradient(135deg, #065f46 0%, #047857 50%, #059669 100%);
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #ecfdf5;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-focus: #059669;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ========================================================================
   Accessibility Focus Styles (P0-C)
   ======================================================================== */

:focus-visible {
    outline: 2px solid var(--primary-600) !important;
    outline-offset: 2px !important;
}

/* Ensure visible focus on buttons and links */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--primary-600) !important;
    outline-offset: 2px !important;
}

/* Adjust for dark theme */
[data-theme="dark"] :focus-visible {
    outline-color: var(--primary-400) !important;
}

/* Parchment Theme - Academic & Warm */
[data-theme="parchment"] {
    --bg-primary: #fffbf5;
    --bg-secondary: #fef7ed;
    --bg-tertiary: #fef3e2;
    --bg-header: linear-gradient(135deg, #78350f 0%, #92400e 50%, #a16207 100%);
    --bg-sidebar: #fffbf5;
    --bg-card: #fffef9;
    --bg-hover: #fef7ed;
    --bg-active: #fef3c7;

    --text-primary: #422006;
    --text-secondary: #78350f;
    --text-tertiary: #92400e;
    --text-muted: #a16207;

    --border-light: #fde68a;
    --border-medium: #fcd34d;
    --border-focus: #a16207;

    --primary-600: #a16207;
    --primary-700: #92400e;
}

/* Dark Theme - Modern & Elegant */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-header: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-active: #064e3b;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    --border-light: #334155;
    --border-medium: #475569;
    --border-focus: #10b981;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

/* Dark theme input fixes */
[data-theme="dark"] .q-field__native,
[data-theme="dark"] .q-field__input,
[data-theme="dark"] input,
[data-theme="dark"] textarea {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-field--outlined .q-field__control {
    background: var(--bg-tertiary) !important;
}

[data-theme="dark"] .q-field__label {
    color: var(--text-tertiary) !important;
}

[data-theme="dark"] .result-snippet,
[data-theme="dark"] .transcription-panel,
[data-theme="dark"] .transcription-content {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Dark Theme Menu Fixes */
[data-theme="dark"] .q-menu {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-light) !important;
}

[data-theme="dark"] .q-item {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-item:hover {
    background: var(--bg-hover) !important;
}

[data-theme="dark"] .highlight-match {
    background: linear-gradient(120deg, #854d0e 0%, #a16207 100%) !important;
    color: white !important;
}

[data-theme="dark"] .line-break-sep {
    color: #aaa !important;
}

/* Dark Theme Tabs Fixes */
[data-theme="dark"] .q-tabs,
[data-theme="dark"] .q-tab-panels {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-tab {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .q-tab--active {
    color: var(--primary-400) !important;
}

/* Dark Theme Dialog Fixes */
[data-theme="dark"] .q-dialog__inner {
    background: transparent !important;
}

[data-theme="dark"] .q-dialog .q-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

/* Dark Theme Expansion Panel Fixes */
[data-theme="dark"] .q-expansion-item {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-expansion-item__content {
    background: var(--bg-secondary) !important;
}

/* Dark Theme Badge and Chip Fixes */
[data-theme="dark"] .q-badge {
    color: white !important;
}

/* Dark Theme Select/Dropdown Fixes */
[data-theme="dark"] .q-select .q-field__native,
[data-theme="dark"] .q-select .q-field__input {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-select__dropdown-icon {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .q-select .q-chip {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

/* Dark theme option/item text in select dropdown */
[data-theme="dark"] .q-item__label {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-item__label--caption {
    color: var(--text-tertiary) !important;
}

/* Fix select popup/virtual scroll in dark mode */
[data-theme="dark"] .q-virtual-scroll__content {
    background: var(--bg-card) !important;
}

[data-theme="dark"] .q-select__dialog {
    background: var(--bg-card) !important;
}

/* Dark Theme Checkbox Fixes */
[data-theme="dark"] .q-checkbox__inner {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .q-checkbox__inner--truthy {
    color: var(--primary-400) !important;
}

[data-theme="dark"] .q-checkbox .q-checkbox__label {
    color: var(--text-primary) !important;
}

/* Parchment theme input fixes */
[data-theme="parchment"] .q-field__native,
[data-theme="parchment"] .q-field__input,
[data-theme="parchment"] input,
[data-theme="parchment"] textarea {
    color: var(--text-primary) !important;
}

/* Catalog Browse Table - theme-aware (high specificity to override Quasar) */
.catalog-browse-table .q-table { table-layout: fixed; width: 100% !important; }
.catalog-browse-table .q-table thead tr th {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    font-weight: 600;
}
.catalog-browse-table .q-table tbody tr td {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}
.catalog-browse-table .q-table tbody tr:hover td {
    background: var(--bg-hover) !important;
}
.catalog-browse-table .q-table__bottom {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
}
.catalog-browse-table .catalog-detail-row td {
    white-space: normal !important;
}

/* ========================================================================
   Base Styles
   ======================================================================== */

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Hebrew text styling */
.hebrew-text, [dir="rtl"] {
    font-family: 'David', 'Frank Ruehl', 'Noto Sans Hebrew', 'SBL Hebrew', serif;
}

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

.q-header {
    background: var(--bg-header) !important;
    box-shadow: var(--shadow-lg) !important;
}

.app-header {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

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

.logo-icon {
    font-size: 2rem;
    color: white;
    opacity: 0.95;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.02em;
}

.logo-version {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    margin-inline-start: 8px;
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.ready { background: #34d399; }
.status-dot.loading { background: #fbbf24; }
.status-dot.error { background: #f87171; }

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

/* ========================================================================
   Sidebar Styles
   ======================================================================== */

.q-drawer {
    background-color: var(--bg-sidebar) !important;
    overflow-x: hidden !important;
}

.q-drawer__content {
    overflow-x: hidden !important;
}

/* Use logical properties for drawer borders - works for both LTR and RTL */
.q-drawer--left {
    border-right: 1px solid var(--border-light) !important;
}

.q-drawer--right {
    border-left: 1px solid var(--border-light) !important;
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 16px 24px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    margin: 2px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-active);
    color: var(--primary-700);
    font-weight: 600;
    border-inline-start: 3px solid var(--primary-600);
}

[data-theme="dark"] .nav-item.active {
    color: var(--primary-400);
    border-inline-start-color: var(--primary-400);
}

.nav-item-icon {
    font-size: 1.25rem;
    opacity: 0.85;
}

.nav-item-badge {
    margin-inline-start: auto;
    background: var(--primary-100);
    color: var(--primary-700);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

[data-theme="dark"] .nav-item-badge {
    background: var(--primary-900);
    color: var(--primary-300);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

/* Global Citation Footer */
.citation-footer {
    background: var(--primary-50, #eff6ff) !important;
    border-top: 1px solid var(--primary-200, #bfdbfe) !important;
    color: var(--primary-800, #1e40af) !important;
    min-height: auto !important;
    padding: 0 !important;
}
.citation-footer a {
    color: var(--primary-700, #1d4ed8) !important;
}
.citation-footer a:hover {
    text-decoration: underline !important;
}
[data-theme="dark"] .citation-footer {
    background: var(--primary-900, #1e3a5f) !important;
    border-top-color: var(--primary-700, #1e40af) !important;
    color: var(--primary-200, #bfdbfe) !important;
}
[data-theme="dark"] .citation-footer a {
    color: var(--primary-300, #93c5fd) !important;
}

/* Hide Hebrew label on mobile */
@media (max-width: 768px) {
    .citation-hebrew-label {
        display: none !important;
    }
}

.theme-switcher {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.theme-btn {
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.7;
}

.theme-btn:hover, .theme-btn.active {
    opacity: 1;
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

/* ========================================================================
   Card Styles
   ======================================================================== */

.q-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all 0.2s ease !important;
}

.q-card:hover {
    box-shadow: var(--shadow-md) !important;
}

.card-elevated {
    box-shadow: var(--shadow-lg) !important;
}

/* ========================================================================
   Button Styles
   ======================================================================== */

.btn-primary {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
    color: white !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    padding: 10px 20px !important;
    transition: all 0.2s !important;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3) !important;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(5, 150, 105, 0.4) !important;
}

.btn-secondary {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-medium) !important;
}

.btn-ghost {
    background: transparent !important;
    color: var(--text-secondary) !important;
}

.btn-ghost:hover {
    background: var(--bg-hover) !important;
}

/* ========================================================================
   Input Styles
   ======================================================================== */

.q-field--outlined .q-field__control {
    border-color: var(--border-medium) !important;
    border-radius: 10px !important;
    background: var(--bg-primary) !important;
}

.q-field--outlined.q-field--focused .q-field__control {
    border-color: var(--border-focus) !important;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15) !important;
}

.q-field__label {
    color: var(--text-secondary) !important;
}

/* ========================================================================
   Content Area
   ======================================================================== */

.main-content {
    background: var(--bg-secondary);
    min-height: calc(100vh - 64px);
    padding: 24px;
}

.content-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

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

/* ========================================================================
   Research-Specific Styles
   ======================================================================== */

/* Result Cards */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

.result-card:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.result-shelfmark {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-700);
}

.result-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.result-snippet {
    font-size: 0.95rem;
    line-height: 1.8;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    direction: rtl;
    text-align: right;
}

.highlight-match {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

.line-break-sep {
    color: #888;
    font-weight: bold;
    padding: 0 2px;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-weight: 500;
}

/* Advanced Options Panel */
.options-panel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
}

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

/* ========================================================================
   Scrollbar Styles
   ======================================================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--neutral-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neutral-500);
}

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

@media (max-width: 768px) {
    .app-header {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.75rem;
    }
}

/* ========================================================================
   Animation Classes
   ======================================================================== */

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.text-gradient {
    background: linear-gradient(135deg, var(--primary-600), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.border-gradient {
    border-image: linear-gradient(135deg, var(--primary-400), var(--accent-gold)) 1;
}

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========================================================================
   Mobile Responsive - Minimal Breakpoints
   ======================================================================== */

/* Mobile select dialog dark mode fixes */
[data-theme="dark"] .q-dialog--menu .q-card,
[data-theme="dark"] .q-select__dialog .q-card {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-dialog--menu .q-item,
[data-theme="dark"] .q-select__dialog .q-item {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .q-dialog--menu .q-item:hover,
[data-theme="dark"] .q-select__dialog .q-item:hover,
[data-theme="dark"] .q-dialog--menu .q-item--active,
[data-theme="dark"] .q-select__dialog .q-item--active {
    background: var(--bg-hover) !important;
}

/* Parchment theme select/dropdown fixes */
[data-theme="parchment"] .q-menu {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-light) !important;
}

[data-theme="parchment"] .q-item {
    color: var(--text-primary) !important;
}

[data-theme="parchment"] .q-item:hover {
    background: var(--bg-hover) !important;
}

[data-theme="parchment"] .q-select .q-field__native {
    color: var(--text-primary) !important;
}

/* Tablet and below */
@media (max-width: 768px) {
    /* Prevent iOS zoom on input focus */
    input, select, textarea { font-size: 16px !important; }

    /* Touch-friendly targets */
    button, .clickable, [role="button"] { min-height: 44px; }

    /* Prevent horizontal scroll */
    body { overflow-x: hidden; }
}

/* Mobile */
@media (max-width: 640px) {
    .app-header { padding: 0 12px; }
    .main-content { padding: 12px; }
    .page-title { font-size: 1.5rem; }
}

/* Small mobile */
@media (max-width: 480px) {
    .main-content { padding: 8px; }
    .page-title { font-size: 1.25rem; }

    /* Dialogs fullscreen */
    .q-dialog__inner { padding: 0 !important; }
    .q-dialog .q-card {
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
    }
}

/* Utility classes */
@media (max-width: 640px) {
    .hide-mobile { display: none !important; }
}
@media (min-width: 641px) {
    .show-mobile-only { display: none !important; }
}

/* === Page-specific mobile styles === */

/* Home page */
@media (max-width: 640px) {
    .tool-card { min-width: 100% !important; }
    .mini-stat-card { padding: 12px !important; }
}

/* Search page */
@media (max-width: 768px) {
    /* Hide viewer panel on mobile - results expand inline instead */
    .search-splitter .q-splitter__after { display: none !important; }
    .search-splitter .q-splitter__separator { display: none !important; }
    .search-splitter .q-splitter__before { width: 100% !important; flex: 1 !important; }
    .filters-grid { grid-template-columns: 1fr !important; }
    /* Show mobile expansion in result cards */
    .result-mobile-expand { display: block !important; }
}
@media (min-width: 769px) {
    /* Hide mobile expansion on desktop */
    .result-mobile-expand { display: none !important; }
}

/* Collapsible Search Panel */
.search-panel-container {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-panel-expanded,
.search-panel-collapsed {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.search-panel-collapsed {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-panel-expanded {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Collapsed panel hover effect */
.search-panel-collapsed:hover {
    background: var(--bg-hover) !important;
}

/* Ensure smooth transition for panel content */
.search-panel-container .q-card {
    will-change: transform, opacity;
}

/* RTL support for collapsed panel */
[dir="rtl"] .search-panel-collapsed .q-row,
.hebrew-mode .search-panel-collapsed .q-row {
    flex-direction: row-reverse;
}

/* Collapsed panel query text RTL */
.search-panel-collapsed .truncate {
    direction: rtl;
    text-align: right;
}

/* Mobile adjustments for collapsible search panel */
@media (max-width: 768px) {
    .search-panel-expanded {
        padding: 12px !important;
    }

    .search-panel-collapsed {
        padding: 8px 12px !important;
    }

    /* Stack search elements vertically on very small screens */
    .search-panel-expanded .flex-wrap {
        gap: 12px !important;
    }

    /* Collapse toggle button more visible on mobile */
    .search-panel-container [class*="expand_less"],
    .search-panel-container [class*="expand_more"] {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 480px) {
    /* Very small screens: hide some labels in collapsed view */
    .search-panel-collapsed .q-badge {
        display: none !important;
    }

    /* Full width search button in collapsed mode */
    .search-panel-collapsed .btn-primary {
        padding: 4px 12px !important;
        font-size: 0.75rem !important;
    }
}

/* Browse page */
@media (max-width: 768px) {
    .browse-container { flex-direction: column !important; }
    .image-panel, .transcription-panel { width: 100% !important; max-height: 50vh !important; }
}

/* Lists page */
@media (max-width: 768px) {
    .lists-layout { flex-direction: column !important; }
    .lists-sidebar { width: 100% !important; max-height: 200px !important; }
}

/* Header mobile adjustments */
@media (max-width: 640px) {
    .app-header { padding: 0 8px !important; }
    .app-header .status-indicator {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
    }
    .app-header .status-indicator .status-text { display: none; }
    .app-header .auth-buttons { gap: 4px !important; }
    .app-header .auth-buttons .q-btn {
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 4px !important;
    }
    /* Hide help button on mobile (keyboard shortcuts not relevant for touch) */
    .help-btn-header { display: none !important; }
    /* Hide logo text on mobile - only show icon */
    .header-logo-text { display: none !important; }
}

/* Ensure logo text doesn't shrink */
.header-logo-text {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

/* Header reveal only on mobile - disable on desktop */
@media (min-width: 769px) {
    .q-header {
        transform: translateY(0) !important;
    }
}

/* Mobile drawer - CSS only, hide on phones/tablets */
/* Handles both LTR (left drawer) and RTL (right drawer) modes */
@media (max-width: 768px) {
    .q-drawer--left:not(.q-drawer--on-top) {
        transform: translateX(-100%) !important;
    }
    .q-drawer--right:not(.q-drawer--on-top) {
        transform: translateX(100%) !important;
    }
}

/* Hebrew mode text direction enhancements */
/* Layout RTL is handled by Quasar natively; these rules enhance text content */

/* Ensure Inputs in Hebrew mode are RTL */
.hebrew-mode input,
.hebrew-mode textarea,
.hebrew-mode .q-field__native,
.hebrew-mode .q-field__input {
    direction: rtl !important;
    text-align: right !important;
}

/* Content Text (Markdown, Paragraphs, Headings) should be RTL in Hebrew */
.hebrew-mode .q-markdown,
.hebrew-mode p,
.hebrew-mode .text-body1,
.hebrew-mode .text-body2,
.hebrew-mode h1,
.hebrew-mode h2,
.hebrew-mode h3,
.hebrew-mode h4,
.hebrew-mode h5,
.hebrew-mode h6,
.hebrew-mode .q-item__label,
.hebrew-mode .q-field__label {
    direction: rtl !important;
    text-align: right !important;
    width: 100%; /* Ensure headings take full width to allow right alignment */
}

/* Ensure main content container aligns text children to right by default in Hebrew */
/* This catches loose text and inline-block elements */
.hebrew-mode .main-content {
    text-align: right;
}

/* Specific overrides for content that must be RTL */
.hebrew-mode .result-snippet,
.hebrew-mode .hebrew-text {
    direction: rtl;
    text-align: right;
}

/* ========================================================================
   Diff Highlighting for Corrections
   ======================================================================== */

.diff-deleted {
    background: #fecaca;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 3px;
    color: #991b1b;
}

.diff-inserted {
    background: #bbf7d0;
    padding: 2px 4px;
    border-radius: 3px;
    color: #166534;
}

[data-theme="dark"] .diff-deleted {
    background: #7f1d1d;
    color: #fecaca;
}

[data-theme="dark"] .diff-inserted {
    background: #14532d;
    color: #bbf7d0;
}

/* ========================================================================
   Fullscreen Edit Mode Overlay
   ======================================================================== */

.fullscreen-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.fullscreen-edit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.fullscreen-edit-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.fullscreen-edit-image-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    overflow: hidden;
}

.fullscreen-image-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    background: #111;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.fullscreen-image-toolbar .q-btn {
    color: #aaa !important;
}

.fullscreen-image-toolbar .q-btn:hover {
    color: #fff !important;
}

.fullscreen-edit-image {
    flex: 1;
    background: #1a1a1a;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-edit-text {
    flex: 1;
    background: var(--bg-primary);
    overflow: hidden;
    padding: 10px;
}

.fullscreen-edit-text .q-textarea {
    height: 100%;
}

.fullscreen-edit-text textarea {
    resize: none !important;
    overflow-y: auto !important;
}

/* Draggable splitter between image and text */
.fullscreen-edit-splitter {
    width: 6px;
    background: var(--border-light);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.2s;
}

.fullscreen-edit-splitter:hover,
.fullscreen-edit-splitter.dragging {
    background: var(--q-primary);
}

/* Fullscreen image should fill and allow pan/zoom */
.fullscreen-edit-image .zoomable-image {
    max-width: none;
    max-height: none;
    transform-origin: center center;
}

@media (max-width: 768px) {
    .fullscreen-edit-content {
        flex-direction: column;
    }
    .fullscreen-edit-image,
    .fullscreen-edit-text {
        flex: 1;
        max-height: 50vh;
    }
    .fullscreen-edit-text {
        border-left: none;
        border-top: 1px solid var(--border-light);
    }
    .fullscreen-edit-splitter {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }
}

/* ========================================================================
   Page Loading Progress Bar - GitHub/YouTube style
   ======================================================================== */

.page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 9999;
    pointer-events: none;
    background: linear-gradient(90deg,
        var(--primary-400) 0%,
        var(--primary-500) 50%,
        var(--primary-400) 100%);
    background-size: 200% 100%;
    transform: translateX(-100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-loading-bar.active {
    opacity: 1;
    animation: loading-progress 1.5s ease-in-out infinite,
               loading-shimmer 1s linear infinite;
}

@keyframes loading-progress {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(-30%); }
    100% { transform: translateX(-10%); }
}

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

.page-loading-bar.complete {
    animation: loading-complete 0.3s ease-out forwards;
}

@keyframes loading-complete {
    0% { transform: translateX(-10%); opacity: 1; }
    100% { transform: translateX(0%); opacity: 0; }
}

/* ========================================================================
   Feature Discovery Glow
   ======================================================================== */

@keyframes feature-glow {
    0%, 100% { box-shadow: 0 0 4px 1px rgba(16, 185, 129, 0.3); }
    50% { box-shadow: 0 0 12px 4px rgba(16, 185, 129, 0.6); }
}

.feature-glow {
    animation: feature-glow 2s ease-in-out infinite;
    border-radius: 8px;
}

.feature-hint {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #065f46;
    color: white;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    pointer-events: none;
    animation: feature-hint-fade 4s ease-in-out forwards;
    z-index: 100;
}

.feature-hint::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #065f46;
}

@keyframes feature-hint-fade {
    0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
    10% { opacity: 1; transform: translateX(-50%) translateY(0); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}
