/* ==========================================================================
   Arabic News Platform — Modern RTL Design System & Stylesheet (v3.0.0)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & Theme Variables
   -------------------------------------------------------------------------- */
:root {
    --font-heading: 'Cairo', system-ui, -apple-system, sans-serif;
    --font-body: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;

    /* Spacing & Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);

    /* Z-Indices */
    --z-sticky: 100;
    --z-drawer: 200;
    --z-modal: 300;
    --z-toast: 400;
}

/* Dark Theme (Default) */
body[data-theme="dark"] {
    --bg-base: #090d16;
    --bg-surface: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #24344d;
    --bg-glass: rgba(15, 23, 42, 0.85);
    --border-color: rgba(148, 163, 184, 0.14);
    --border-focus: #38bdf8;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-sky: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --accent-emerald: #10b981;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Light Theme */
body[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.9);
    --border-color: #e2e8f0;
    --border-focus: #0284c7;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-sky: #0284c7;
    --accent-indigo: #4f46e5;
    --accent-red: #dc2626;
    --accent-amber: #d97706;
    --accent-emerald: #059669;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.12);
}

/* --------------------------------------------------------------------------
   2. Base & Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    direction: rtl;
    text-align: right;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding-bottom: 70px; /* Space for mobile bottom bar */
}

@media (min-width: 769px) {
    body {
        padding-bottom: 0;
    }
}

a {
    color: var(--accent-sky);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    text-decoration: underline;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

.hidden {
    display: none !important;
}

/* --------------------------------------------------------------------------
   3. Header & Navigation
   -------------------------------------------------------------------------- */
.offline-banner {
    background-color: var(--accent-amber);
    color: #0f172a;
    padding: 8px 16px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background-color: var(--bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-color);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none !important;
}

.brand-logo {
    border-radius: var(--radius-sm);
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.2;
    background: linear-gradient(135deg, var(--accent-sky), var(--accent-indigo));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-emerald);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
    animation: livePulse 2s infinite;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 6px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background-color: rgba(56, 189, 248, 0.15);
    color: var(--accent-sky);
    font-weight: 700;
}

.main-nav {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    gap: 8px;
    border-top: 1px solid var(--border-color);
}

@media (min-width: 769px) {
    .main-nav {
        display: flex;
    }
}

.nav-tab {
    padding: 10px 18px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

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

.nav-tab.active {
    color: var(--accent-sky);
    border-bottom-color: var(--accent-sky);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    background-color: var(--bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 6px 12px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none;
    }
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mobile-nav-btn i {
    font-size: 1.15rem;
}

.mobile-nav-btn.active {
    color: var(--accent-sky);
}

/* --------------------------------------------------------------------------
   4. Main Content Layout
   -------------------------------------------------------------------------- */
.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

.view-section {
    animation: fadeIn 0.25s ease-out;
}

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

/* --------------------------------------------------------------------------
   5. Login View
   -------------------------------------------------------------------------- */
.login-section {
    min-height: calc(100vh - 160px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px 28px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    margin-bottom: 14px;
}

.login-header h2 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea,
.modal-body input:not([type="checkbox"]):not([type="radio"]),
.modal-body select,
.modal-body textarea,
.section-item-input {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-card, #1e293b);
    border: 1px solid var(--border-color, #334155);
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, #f8fafc);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus,
.modal-body input:not([type="checkbox"]):not([type="radio"]):focus,
.modal-body select:focus,
.modal-body textarea:focus,
.section-item-input:focus {
    outline: none;
    border-color: var(--border-focus, #38bdf8);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input-icon {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-wrap input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-wrap input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.toggle-password-btn {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    padding: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    border-radius: var(--radius-md);
    padding: 10px 18px;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-sky), var(--accent-indigo));
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-outline {
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-focus);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.alert-box {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    font-weight: 500;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   6. Timeline & Feed View
   -------------------------------------------------------------------------- */
.topics-bar-wrap {
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 14px;
    -webkit-overflow-scrolling: touch;
}

.topics-bar {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.topic-chip:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.topic-chip.active {
    background: linear-gradient(135deg, var(--accent-sky), var(--accent-indigo));
    color: #ffffff;
    border-color: transparent;
}

.topic-chip.urgent-chip.active {
    background: var(--accent-red);
}

.feed-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

@media (min-width: 640px) {
    .feed-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

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

.search-box .search-icon {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 10px 42px 10px 38px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.clear-search-btn {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    padding: 4px;
}

.filter-chips {
    display: flex;
    gap: 6px;
}

.filter-chip {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-chip.active {
    background-color: var(--text-primary);
    color: var(--bg-base);
    border-color: transparent;
}

.live-update-toast {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(99, 102, 241, 0.15));
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: pulseBorder 2s infinite;
}

@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.pulse-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-red);
    display: inline-block;
    animation: livePulse 1.4s infinite;
}

/* Feed Stream & Cards */
.feed-stream {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.feed-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.feed-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(56, 189, 248, 0.3);
}

/* Summary Card */
.summary-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.summary-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topic-badge {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background-color: rgba(56, 189, 248, 0.12);
    color: var(--accent-sky);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.time-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.message-count-badge {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    color: var(--text-secondary);
}

.summary-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text-primary);
}

/* Summary Collapsible Section */
.summary-section {
    margin-bottom: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-card);
}

.summary-section-header {
    width: 100%;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-card);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    border-bottom: 1px solid transparent;
    transition: var(--transition);
}

.summary-section-header:hover {
    background-color: var(--bg-card-hover);
}

.summary-section-header.expanded {
    border-bottom-color: var(--border-color);
}

.summary-section-header i.chevron {
    transition: transform 0.25s ease;
}

.summary-section-header.expanded i.chevron {
    transform: rotate(180deg);
}

.summary-section-body {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-point {
    position: relative;
    padding-right: 22px;
    font-size: 0.95rem;
    line-height: 1.7;
}

.summary-point-bullet {
    position: absolute;
    right: 0;
    top: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-sky);
}

.source-pill {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.78rem;
    border: 1px solid var(--border-color);
}

/* Section Header Badge Title */
.section-badge-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Clean Formatted Summary Bullets */
.summary-bullet {
    position: relative;
    font-size: 0.98rem;
    line-height: 1.9;
    margin-bottom: 12px;
    color: var(--text-primary);
    word-break: break-word;
}

.summary-bullet:last-child {
    margin-bottom: 0;
}

/* Bracketed Keywords Highlight Pill */
.kw-highlight {
    display: inline-block;
    padding: 1px 6px;
    margin: 0 2px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.94em;
    background: rgba(56, 189, 248, 0.14);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    transition: background 0.15s ease;
}

[data-theme="light"] .kw-highlight {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    border-color: rgba(2, 132, 199, 0.25);
}

/* Muted Distinct Source Badge */
.source-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--bg-surface, rgba(148, 163, 184, 0.12));
    border: 1px solid var(--border-color, #334155);
    border-radius: 6px;
    padding: 2px 8px;
    margin-top: 4px;
    margin-right: 4px;
    white-space: nowrap;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Urgent Alert Card */
.urgent-card {
    border-right: 4px solid var(--accent-red);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), var(--bg-surface));
}

.urgent-badge {
    background-color: var(--accent-red);
    color: #ffffff;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.keyword-badge {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.urgent-text {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.6;
    margin: 12px 0;
    color: var(--text-primary);
}

.urgent-sources-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   7. Media Gallery
   -------------------------------------------------------------------------- */
.media-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    background-color: var(--bg-surface);
    padding: 12px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.media-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-select {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.media-type-pills {
    display: flex;
    gap: 6px;
}

.type-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}

.type-pill.active {
    background-color: var(--accent-sky);
    color: #ffffff;
    border-color: transparent;
}

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.switch-label input {
    display: none;
}

.switch-slider {
    width: 38px;
    height: 20px;
    background-color: var(--bg-card);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    position: relative;
    transition: var(--transition);
}

.switch-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--text-muted);
    top: 2px;
    right: 3px;
    transition: var(--transition);
}

.switch-label input:checked + .switch-slider {
    background-color: var(--accent-sky);
    border-color: var(--accent-sky);
}

.switch-label input:checked + .switch-slider::before {
    transform: translateX(-17px);
    background-color: #ffffff;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.media-card {
    position: relative;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    aspect-ratio: 16 / 10;
}

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

.media-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background-color: var(--bg-card);
}

.media-badge-type {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
}

.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
    padding: 20px 10px 8px;
    color: #ffffff;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   8. Admin Panel Styles
   -------------------------------------------------------------------------- */
.admin-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-header-row {
    background-color: var(--bg-surface);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.admin-title h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.admin-title p {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.admin-subtabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.admin-subtab {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: var(--transition);
}

.admin-subtab:hover {
    color: var(--text-primary);
    background-color: var(--bg-card);
}

.admin-subtab.active {
    background: linear-gradient(135deg, var(--accent-sky), var(--accent-indigo));
    color: #ffffff;
    border-color: transparent;
}

.admin-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-header-actions h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th, .data-table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-card);
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background-color: var(--bg-card-hover);
}

/* System Stats Cards */
.system-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #ffffff;
}

.bg-info { background-color: var(--accent-sky); }
.bg-success { background-color: var(--accent-emerald); }
.bg-danger { background-color: var(--accent-red); }
.bg-primary { background-color: var(--accent-indigo); }
.bg-warning { background-color: var(--accent-amber); }
.bg-secondary { background-color: var(--text-muted); }

.stat-meta {
    display: flex;
    flex-direction: column;
}

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

.stat-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.section-box {
    margin-top: 24px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
}

.section-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

/* Schedules Grid */
.schedules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.schedule-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.schedule-topic-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   9. Drawers & Modals
   -------------------------------------------------------------------------- */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-drawer);
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: flex-end;
}

.drawer-panel {
    width: 100%;
    max-width: 520px;
    height: 100%;
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.28s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
}

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

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.drawer-item-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.drawer-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.drawer-item-text {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox-dialog {
    position: relative;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.lightbox-close-btn {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.lightbox-media-container {
    width: 100%;
    max-height: 65vh;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-media-container img, .lightbox-media-container video {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
}

.lightbox-details {
    padding: 16px 20px;
    background-color: var(--bg-surface);
}

.lightbox-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.lightbox-caption {
    font-size: 0.95rem;
    line-height: 1.6;
}

.lightbox-fallback-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-telegram {
    background-color: #229ed9;
    color: #ffffff;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-dialog {
    width: 100%;
    max-width: 580px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: zoomIn 0.22s ease-out;
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
}

.modal-body {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 20px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

@media (min-width: 769px) {
    .toast-container {
        bottom: 24px;
    }
}

.toast {
    pointer-events: auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    animation: slideUp 0.24s ease-out;
    max-width: 360px;
}

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

.toast-success { border-right: 4px solid var(--accent-emerald); }
.toast-error { border-right: 4px solid var(--accent-red); }
.toast-info { border-right: 4px solid var(--accent-sky); }

/* Spinners */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner-large {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(56, 189, 248, 0.2);
    border-top-color: var(--accent-sky);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-state, .empty-state {
    padding: 48px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
}

.pagination-wrap {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}