/* ==========================================================================
   ai-books Streaming Web Viewer — Modern Dark Glassmorphic Theme
   Pure CSS3 with Zero External Dependencies
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-base: #090a0f;
    --bg-surface: #0f111a;
    --bg-surface-elevated: #151824;
    --bg-card: rgba(21, 24, 38, 0.72);
    --bg-card-hover: rgba(30, 35, 55, 0.88);
    --bg-glass: rgba(15, 17, 26, 0.8);
    --bg-glass-modal: rgba(9, 10, 15, 0.85);

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.15);
    --border-focus: #6366f1;
    --border-accent: rgba(99, 102, 241, 0.35);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --text-dim: #475569;

    /* Accent & Brand */
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #38bdf8 100%);
    --accent-glow: rgba(99, 102, 241, 0.25);

    /* Status Colors */
    --status-pending: #64748b;
    --status-running: #0ea5e9;
    --status-complete: #10b981;
    --status-challenge: #f59e0b;
    --status-timeout: #f97316;
    --status-error: #ef4444;

    /* Stock Badge Colors */
    --stock-in-bg: rgba(16, 185, 129, 0.15);
    --stock-in-text: #34d399;
    --stock-in-border: rgba(16, 185, 129, 0.3);

    --stock-low-bg: rgba(245, 158, 11, 0.15);
    --stock-low-text: #fbbf24;
    --stock-low-border: rgba(245, 158, 11, 0.3);

    --stock-out-bg: rgba(239, 68, 68, 0.15);
    --stock-out-text: #f87171;
    --stock-out-border: rgba(239, 68, 68, 0.3);

    --stock-notify-bg: rgba(168, 85, 247, 0.15);
    --stock-notify-text: #c084fc;
    --stock-notify-border: rgba(168, 85, 247, 0.3);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', sans-serif;
    --font-arabic: 'Amiri', 'Traditional Arabic', 'Scheherazade New', 'Tahoma', serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Layout & Sizing */
    --sidebar-width: 320px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-card: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px -2px rgba(99, 102, 241, 0.3);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

html, body {
    height: 100%;
    width: 100%;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* Sleek Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.24);
}

/* Helpers */
.hidden {
    display: none !important;
}

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

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar Styling
   ========================================================================== */

.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    user-select: none;
    z-index: 50;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.brand-icon {
    font-size: 1.35rem;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.version-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-tagline {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* Sidebar Recent Searches */
.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.25rem 1rem 0.5rem 1rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    padding: 0 0.25rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-subtle);
}

.history-container {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.query-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.query-item {
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.query-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-subtle);
    transform: translateX(2px);
}

.query-item.active {
    background: rgba(99, 102, 241, 0.12);
    border-color: var(--border-accent);
}

.query-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.query-item-text {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}

.query-item.active .query-item-text {
    color: #e0e7ff;
    font-weight: 600;
}

.query-item-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.query-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.history-empty, .history-loading {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.spinner-small {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-pending);
}

.status-dot.online {
    background: var(--status-complete);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.status-dot.busy {
    background: var(--status-running);
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.8);
    animation: pulse 1.2s infinite;
}

.status-label {
    color: var(--text-muted);
    font-weight: 500;
}

.footer-meta {
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

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

.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.05) 0%, transparent 60%),
                var(--bg-base);
}

/* Mobile Nav Bar */
.mobile-nav-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.mobile-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-weight: 700;
}

.mobile-pulse .pulse-indicator-dot {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-complete);
}

/* Search Header */
.search-header {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.25rem 1.75rem 1rem 1.75rem;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
}

.search-input-group {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1.1rem;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 2.5rem 0 3.2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    transition: var(--transition-fast);
    outline: none;
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.clear-input-btn {
    position: absolute;
    right: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.clear-input-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.2);
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Primary and Secondary Buttons */
.btn {
    height: 48px;
    padding: 0 1.35rem;
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-base);
    border: 1px solid transparent;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    filter: brightness(1.08);
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-medium);
    color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.btn-secondary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Store Filter Bar */
.store-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.store-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
}

.store-filter-title-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.store-filter-title {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.store-filter-count {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.12);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

.store-filter-presets {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.preset-btn.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--border-accent);
    color: #c7d2fe;
    font-weight: 500;
}

.store-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-height: 80px;
    overflow-y: auto;
    padding-bottom: 0.2rem;
}

.store-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}

.store-pill:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
}

.store-pill.selected {
    background: rgba(99, 102, 241, 0.16);
    border-color: rgba(99, 102, 241, 0.45);
    color: #e0e7ff;
    box-shadow: 0 0 10px -2px rgba(99, 102, 241, 0.3);
}

.store-pill .pill-check {
    font-size: 0.65rem;
    opacity: 0;
    transition: var(--transition-fast);
}

.store-pill.selected .pill-check {
    opacity: 1;
    color: #818cf8;
}

.store-pill .pill-platform {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.store-pill.selected .pill-platform {
    color: #a5b4fc;
}

/* ==========================================================================
   Workspace Scrollable Area
   ========================================================================== */

.workspace-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem 3rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   Real-Time Progress & Telemetry Bar
   ========================================================================== */

.telemetry-section {
    width: 100%;
}

.telemetry-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    box-shadow: var(--shadow-card);
}

.telemetry-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.active-query-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.telemetry-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
}

.active-query-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.telemetry-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(14, 165, 233, 0.35);
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
}

.telemetry-status-badge.complete {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
    color: #34d399;
}

.telemetry-status-badge.cancelled {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

.badge-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.4s infinite;
}

/* Telemetry Metrics Grid */
.telemetry-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem;
}

.metric-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.metric-icon {
    font-size: 1.25rem;
}

.metric-details {
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

#metricTtfc.highlight {
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

/* Progress Bar */
.progress-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.progress-bar-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Soft Deadline Banner */
.soft-deadline-alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #fbbf24;
    font-size: 0.82rem;
    animation: fadeIn 0.3s ease;
}

.alert-icon {
    font-size: 1.15rem;
}

/* Job Complete Banner */
.job-summary-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(99, 102, 241, 0.12) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    animation: fadeIn 0.4s ease;
}

.summary-icon {
    font-size: 1.8rem;
}

.summary-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: #34d399;
    font-weight: 700;
}

.summary-details {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Per-Store Status Checklist Grid
   ========================================================================== */

.store-checklist-section {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.checklist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.checklist-title {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.checklist-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.checklist-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.checklist-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.store-checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.65rem;
    transition: max-height var(--transition-smooth);
}

.store-status-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.store-status-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--status-pending);
    transition: background var(--transition-fast);
}

/* Status variants */
.store-status-card.pending::before { background: var(--status-pending); }
.store-status-card.running::before { background: var(--status-running); box-shadow: 0 0 8px var(--status-running); }
.store-status-card.complete::before { background: var(--status-complete); }
.store-status-card.challenge::before { background: var(--status-challenge); }
.store-status-card.timeout::before { background: var(--status-timeout); }
.store-status-card.error::before { background: var(--status-error); }

.store-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.store-card-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.store-card-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.store-card-badge {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.store-card-badge.pending {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.store-card-badge.running {
    background: rgba(14, 165, 233, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.4);
}

.store-card-badge.running .badge-spinner {
    width: 10px;
    height: 10px;
    border: 2px solid rgba(56, 189, 248, 0.3);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.store-card-badge.complete {
    background: rgba(16, 185, 129, 0.16);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.store-card-badge.challenge {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.store-card-badge.timeout {
    background: rgba(249, 115, 22, 0.18);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.store-card-badge.error {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   Results Toolbar
   ========================================================================== */

.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.results-counter-group {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.results-counter-num {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: #e0e7ff;
}

.results-counter-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-pill {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

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

.filter-pill.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--border-accent);
    color: #c7d2fe;
    font-weight: 500;
}

.inline-filter-input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    outline: none;
    width: 140px;
    transition: var(--transition-fast);
}

.inline-filter-input:focus {
    border-color: var(--border-focus);
    width: 170px;
}

.sort-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sort-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sort-select {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    outline: none;
    cursor: pointer;
}

.view-mode-toggle {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.3rem 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

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

.view-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
}

/* ==========================================================================
   Results Container & Empty State
   ========================================================================== */

.results-container {
    width: 100%;
    min-height: 250px;
}

.empty-state {
    padding: 3.5rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 620px;
    margin: 0 auto;
}

.empty-state-art {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
    border: 1px solid var(--border-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.empty-state-emoji {
    font-size: 2.2rem;
}

.empty-state-title {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.sample-query {
    color: #a5b4fc;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    font-weight: 500;
}

.sample-query:hover {
    color: #ffffff;
}

.empty-features-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.feature-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chip-icon {
    font-size: 0.85rem;
}

/* ==========================================================================
   Progressive Book Card Grid
   ========================================================================== */

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

/* List view mode */
.book-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.book-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition-base);
    animation: cardEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
}

.book-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-medium);
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.5), 0 0 16px -2px rgba(99, 102, 241, 0.2);
}

/* Card Media / Thumbnail */
.card-media-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
}

.card-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-smooth);
}

.book-card:hover .card-cover-img {
    transform: scale(1.04);
}

.card-store-badge {
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    background: rgba(15, 17, 26, 0.85);
    backdrop-filter: blur(8px);
    color: #e2e8f0;
    border: 1px solid var(--border-medium);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-zoom-hint {
    position: absolute;
    bottom: 0.65rem;
    right: 0.65rem;
    background: rgba(15, 17, 26, 0.75);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
    font-size: 0.75rem;
    opacity: 0;
    transition: var(--transition-fast);
}

.card-media-wrapper:hover .card-zoom-hint {
    opacity: 1;
}

/* Card Body */
.card-body {
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1;
}

.card-title-link {
    text-decoration: none;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: color var(--transition-fast);
}

.card-title-link:hover {
    color: #818cf8;
}

.card-title-link[dir="rtl"] {
    font-family: var(--font-arabic);
    font-size: 1.15rem;
    line-height: 1.5;
}

.card-meta-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-author, .card-publisher {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-author strong, .card-publisher strong {
    color: var(--text-dim);
    font-weight: 500;
}

/* Card Price & Stock */
.card-footer-info {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-price-group {
    display: flex;
    flex-direction: column;
}

.card-price-current {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: #34d399;
}

.card-price-original {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-decoration: line-through;
    color: var(--text-dim);
}

.stock-pill {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stock-pill.stock-in {
    background: var(--stock-in-bg);
    color: var(--stock-in-text);
    border: 1px solid var(--stock-in-border);
}

.stock-pill.stock-low {
    background: var(--stock-low-bg);
    color: var(--stock-low-text);
    border: 1px solid var(--stock-low-border);
}

.stock-pill.stock-out {
    background: var(--stock-out-bg);
    color: var(--stock-out-text);
    border: 1px solid var(--stock-out-border);
}

.stock-pill.stock-notify {
    background: var(--stock-notify-bg);
    color: var(--stock-notify-text);
    border: 1px solid var(--stock-notify-border);
}

.stock-pill.stock-preorder {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

/* Card Action Button */
.card-action-btn {
    width: 100%;
    margin-top: 0.65rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

.card-action-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--border-accent);
    color: #e0e7ff;
}

/* List View Layout Overrides */
.book-grid.list-view .book-card {
    flex-direction: row;
    max-height: 130px;
}

.book-grid.list-view .card-media-wrapper {
    width: 100px;
    height: 100%;
    aspect-ratio: auto;
    flex-shrink: 0;
}

.book-grid.list-view .card-body {
    padding: 0.75rem 1.25rem;
    display: grid;
    grid-template-columns: 2fr 1.2fr 1fr 120px;
    align-items: center;
    gap: 1rem;
}

.book-grid.list-view .card-footer-info {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-direction: column;
    align-items: flex-start;
}

.book-grid.list-view .card-action-btn {
    margin-top: 0;
}

/* ==========================================================================
   Image Modal (High-Res Cover Inspection)
   ========================================================================== */

.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-glass-modal);
    backdrop-filter: blur(16px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.25s ease;
}

.image-modal-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-xl);
    max-width: 840px;
    width: 100%;
    max-height: 90vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    overflow: hidden;
    position: relative;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
}

.modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.15);
}

.modal-image-wrapper {
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    max-height: 90vh;
    overflow: hidden;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.modal-info {
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

.modal-store-pill {
    display: inline-flex;
    align-self: flex-start;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.18);
    color: #a5b4fc;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.modal-title[dir="rtl"] {
    font-family: var(--font-arabic);
    font-size: 1.65rem;
}

.modal-price-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-price {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: #34d399;
}

.modal-stock {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.modal-action-btn {
    margin-top: auto;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
}

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

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 120;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.2rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
    max-width: 360px;
}

.toast.toast-error {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(30, 15, 20, 0.95);
    color: #fca5a5;
}

.toast.toast-success {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(15, 30, 24, 0.95);
    color: #86efac;
}

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

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

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

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

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

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

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

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 280px 1fr;
    }
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 840px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        height: 100vh;
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        display: block;
    }

    .mobile-nav-bar {
        display: flex;
    }

    .search-header {
        padding: 1rem;
    }

    .search-form {
        flex-direction: column;
    }

    .search-actions {
        width: 100%;
    }

    .search-actions .btn {
        flex: 1;
    }

    .workspace-scrollable {
        padding: 1rem 1rem 3rem 1rem;
    }

    .image-modal-card {
        grid-template-columns: 1fr;
        max-height: 85vh;
    }

    .modal-image-wrapper {
        max-height: 40vh;
    }

    .modal-info {
        padding: 1.5rem;
    }
}
