/**
 * ZAHRA TV Admin - Premium Cinematic OTT Theme
 * Design System: DESIGN.md
 * Accent: Red (#FF2E63) | Background: Ultra Dark
 * Mobile-first responsive redesign
 */

/* ========== DESIGN TOKENS ========== */
:root {
    /* Primary Colors */
    --primary: #FF2E63;
    --primary-light: #FF5C8A;
    --primary-dark: #D4244F;
    --primary-glow: rgba(255, 46, 99, 0.30);
    --primary-subtle: rgba(255, 46, 99, 0.08);

    /* Background Layers */
    --bg-dark: #0B0B0B;
    --bg-surface: #151515;
    --bg-card: #1C1C1C;
    --bg-hover: #252525;
    --bg-glass: rgba(21, 21, 21, 0.80);
    --bg-glass-strong: rgba(11, 11, 11, 0.90);

    /* Text */
    --text-primary: #F5F5F5;
    --text-secondary: #A1A1A1;
    --text-hint: #606060;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-active: rgba(255, 46, 99, 0.40);

    /* Semantic Colors */
    --success: #4CAF50;
    --danger: #E53935;
    --warning: #FFB300;
    --info: #29B6F6;

    /* Border Radius (from DESIGN.md) */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;

    /* Shadow & Glow (from DESIGN.md) */
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4);
    --glow-primary: 0 0 20px rgba(255, 46, 99, 0.4);
    --glow-primary-sm: 0 0 12px rgba(255, 46, 99, 0.25);

    /* Layout */
    --sidebar-width: 260px;
    --bottom-nav-height: 64px;
    --topbar-height: 60px;

    /* Transitions (from DESIGN.md motion) */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-cinematic: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== RESET ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-smooth);
    will-change: transform;
}

/* Subtle gradient glow at sidebar top */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(180deg, rgba(255, 46, 99, 0.06) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.sidebar-brand h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.sidebar-brand .badge {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    font-size: 9px;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: var(--glow-primary-sm);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    overscroll-behavior: contain;
    position: relative;
    z-index: 1;
}

.nav-section {
    padding: 10px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-hint);
    margin-top: 12px;
    font-weight: 600;
}

.nav-section:first-child {
    margin-top: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
    cursor: pointer;
    min-height: 44px;
    position: relative;
}

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

.nav-item.active {
    color: var(--primary);
    background: rgba(255, 46, 99, 0.10);
    border-left-color: var(--primary);
    font-weight: 600;
}

.nav-item.active::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    box-shadow: var(--glow-primary-sm);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.nav-item .badge {
    margin-left: auto;
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.sidebar-footer .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: var(--glow-primary-sm);
    color: #fff;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
}

/* ========== TOPBAR ========== */
.topbar {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: var(--bg-glass-strong);
    height: var(--topbar-height);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.topbar-left h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-right .btn-text {
    display: inline;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.btn-menu-toggle:active {
    background: rgba(255, 255, 255, 0.06);
}

/* ========== PAGE CONTENT ========== */
.page-content {
    padding: 24px;
    overflow-x: hidden;
    max-width: 100%;
}

/* ========== STAT CARDS ========== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 24px;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

/* Decorative gradient orb in corner */
.stat-card::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 46, 99, 0.08) 0%, transparent 70%);
    transition: all var(--transition-smooth);
    pointer-events: none;
}

.stat-card:hover {
    border-color: var(--border-active);
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), var(--glow-primary-sm);
}

.stat-card:hover::before {
    background: radial-gradient(circle, rgba(255, 46, 99, 0.15) 0%, transparent 70%);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
}

.stat-card .stat-trend {
    font-size: 12px;
    margin-top: 8px;
}

/* ========== TABLE CARDS ========== */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: border-color var(--transition-smooth);
    padding: 20px;
}

.table-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

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

.table-card .card-header h5 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-hint);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-secondary);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--primary-subtle);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== BADGES ========== */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.badge-gold {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: #000;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.25);
}
.badge-silver {
    background: linear-gradient(135deg, #C0C0C0, #909090);
    color: #000;
    font-weight: 700;
}
.badge-bronze {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: #fff;
    font-weight: 700;
}
.badge-active {
    background: rgba(76, 175, 80, 0.12);
    color: #66BB6A;
}
.badge-expired {
    background: rgba(229, 57, 53, 0.12);
    color: #EF5350;
}
.badge-warning-glow {
    background: rgba(255, 179, 0, 0.12);
    color: #FFB300;
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.15);
}
.badge-online {
    background: rgba(76, 175, 80, 0.12);
    color: #66BB6A;
}
.badge-offline {
    background: rgba(229, 57, 53, 0.12);
    color: #EF5350;
}

/* ========== BUTTONS ========== */
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: #fff;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-smooth);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.btn-primary-custom::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-primary-custom:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 46, 99, 0.35);
}

.btn-primary-custom:hover::before {
    opacity: 1;
}

.btn-primary-custom:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 46, 99, 0.25);
}

.btn-primary-custom > * {
    position: relative;
    z-index: 1;
}

.btn-outline-custom {
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-outline-custom:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.btn-outline-custom.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(255, 46, 99, 0.12);
}

.btn-sm-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    flex-shrink: 0;
}

.btn-sm-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-subtle);
}

.btn-sm-icon.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(229, 57, 53, 0.08);
}

/* ========== FORM CONTROLS ========== */
.form-control, .form-select {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    transition: all var(--transition-fast);
    min-height: 44px;
}

.form-control:focus, .form-select:focus {
    background: #0a0a0a;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 46, 99, 0.12);
    color: var(--text-primary);
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ========== MODAL ========== */
.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.modal-header .modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
}

/* ========== ALERT WIDGETS ========== */
.alert-widget {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition-smooth);
}

.alert-widget:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.alert-widget .alert-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.015);
}

.alert-widget .alert-header h6 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.alert-widget .alert-body {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.alert-widget .alert-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    transition: background var(--transition-fast);
    gap: 12px;
}

.alert-widget .alert-item:hover {
    background: var(--primary-subtle);
}

.alert-widget .alert-item:last-child {
    border-bottom: none;
}

/* ========== RUNNING TEXT PREVIEW ========== */
.running-text-preview {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    height: 48px;
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
}

.running-text-preview .marquee {
    white-space: nowrap;
    animation: marquee 15s linear infinite;
}

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

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ========== SORTABLE ========== */
.sortable-ghost {
    opacity: 0.4;
    background: rgba(255, 46, 99, 0.08) !important;
}

.sortable-drag {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.sort-handle {
    cursor: grab;
    color: var(--text-hint);
}

.sort-handle:active {
    cursor: grabbing;
}

/* ========== BOTTOM NAVIGATION (Mobile) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    z-index: 1001;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    background: rgba(11, 11, 11, 0.85);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 0 8px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-hint);
    font-size: 10px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: var(--radius);
    transition: all var(--transition-smooth);
    position: relative;
    min-width: 56px;
}

.bottom-nav-item i {
    font-size: 20px;
    transition: all var(--transition-bounce);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active i {
    transform: scale(1.15);
    filter: drop-shadow(0 0 6px rgba(255, 46, 99, 0.5));
}

/* Glow pill indicator */
.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 10px rgba(255, 46, 99, 0.5);
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 2px 10px rgba(255, 46, 99, 0.4); }
    50% { box-shadow: 0 2px 18px rgba(255, 46, 99, 0.7); }
}

/* Bottom nav "more" menu */
.bottom-nav-more-menu {
    display: none;
    position: fixed;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 60vh;
    overflow-y: auto;
}

.bottom-nav-more-menu.show {
    display: block;
}

.bottom-nav-more-menu .more-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.bottom-nav-more-menu .more-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 8px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    transition: all var(--transition-smooth);
    min-height: 76px;
}

.bottom-nav-more-menu .more-menu-item i {
    font-size: 24px;
    color: var(--primary);
    transition: transform var(--transition-bounce);
}

.bottom-nav-more-menu .more-menu-item.active {
    background: rgba(255, 46, 99, 0.10);
    border-color: var(--border-active);
    color: var(--primary);
    box-shadow: var(--glow-primary-sm);
}

.bottom-nav-more-menu .more-menu-item:active {
    transform: scale(0.95);
}

.bottom-nav-more-menu .more-menu-item:active i {
    transform: scale(1.1);
}

.bottom-nav-more-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.bottom-nav-more-overlay.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* ========== MOBILE DATA CARDS ========== */
.mobile-card-list {
    display: none;
}

.mobile-data-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    transition: all var(--transition-fast);
}

.mobile-data-card:active {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

.mobile-data-card .card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mobile-data-card .card-row:last-child {
    margin-bottom: 0;
}

.mobile-data-card .card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.mobile-data-card .card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.mobile-data-card .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.mobile-data-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* ========== MOBILE TOOLBAR ========== */
.mobile-toolbar {
    display: none;
}

/* ========== RESPONSIVE — TABLET ========== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 6px 0 40px rgba(0, 0, 0, 0.6);
    }

    .main-content {
        margin-left: 0;
    }

    .btn-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 999;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .sidebar-overlay.show {
        display: block;
        animation: fadeIn 0.25s ease;
    }
}

/* ========== RESPONSIVE — PHONE ========== */
@media (max-width: 768px) {
    :root {
        --topbar-height: 56px;
    }

    /* Prevent horizontal overflow globally */
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    /* Show bottom nav */
    .bottom-nav {
        display: block;
    }

    /* Add bottom spacing */
    .main-content {
        margin-left: 0;
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Topbar compact */
    .topbar {
        padding: 10px 16px;
    }

    .topbar-left {
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .topbar-left h4 {
        font-size: 16px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-right .btn-text {
        display: none;
    }

    .topbar-right .btn {
        padding: 6px 10px;
    }

    /* Page content compact */
    .page-content {
        padding: 16px;
        overflow-x: hidden;
    }

    /* Fix Bootstrap rows from overflowing */
    .row {
        margin-left: 0;
        margin-right: 0;
    }

    .row > * {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Flex layouts — prevent child overflow */
    .d-flex {
        min-width: 0;
    }

    .d-flex > * {
        min-width: 0;
    }

    /* Input groups fit within screen */
    .input-group {
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }

    /* Form selects and controls fit within parent */
    .form-control, .form-select {
        width: 100%;
        max-width: 100%;
    }

    /* Button groups wrap on mobile */
    .btn-group {
        flex-wrap: wrap !important;
        overflow-x: visible !important;
        max-width: 100%;
    }

    .btn-group .btn {
        flex: 0 0 auto;
        min-width: 0;
    }

    /* Toolbar buttons and dropdowns */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .d-flex.gap-2 > .dropdown,
    .d-flex.gap-2 > .btn {
        flex: 1 1 auto;
        min-width: 120px;
        max-width: 100%;
    }

    /* Ensure toolbar doesn't overflow */
    .d-flex.flex-column.flex-md-row.gap-3 {
        overflow-x: hidden;
    }

    /* Stat cards mobile */
    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 18px;
        margin-bottom: 12px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .stat-card .stat-label {
        font-size: 11px;
    }

    .stat-card:hover {
        transform: none;
        box-shadow: none;
    }

    /* Alert widgets compact */
    .alert-widget .alert-header {
        padding: 12px 16px;
    }

    .alert-widget .alert-header h6 {
        font-size: 13px;
    }

    .alert-widget .alert-item {
        padding: 10px 16px;
        font-size: 12px;
    }

    .alert-widget .alert-body {
        max-height: 220px;
    }

    /* Table card compact */
    .table-card .card-header {
        padding: 14px 16px;
    }

    .table-card .card-header h5 {
        font-size: 14px;
    }

    .data-table thead th {
        padding: 10px 12px;
        font-size: 10px;
    }

    .data-table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* Hide desktop table, show mobile cards */
    .desktop-table-wrapper {
        display: none;
    }

    .mobile-card-list {
        display: block;
    }

    /* Mobile toolbar */
    .desktop-toolbar {
        display: none;
    }

    .mobile-toolbar {
        display: block;
        margin-bottom: 16px;
    }

    .mobile-toolbar .search-wrapper {
        margin-bottom: 10px;
    }

    .mobile-toolbar .filter-row {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .mobile-toolbar .filter-row::-webkit-scrollbar {
        display: none;
    }

    .mobile-toolbar .filter-row .form-select,
    .mobile-toolbar .filter-row .btn {
        flex-shrink: 0;
        font-size: 12px;
        min-height: 36px;
        padding: 4px 10px;
    }

    .mobile-toolbar .action-row {
        display: flex;
        gap: 8px;
        margin-top: 10px;
    }

    .mobile-toolbar .action-row .btn {
        flex: 1;
    }

    /* Modal fullscreen on mobile */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100% - 16px);
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100% - 16px);
    }

    .modal-content {
        border-radius: var(--radius);
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    /* Toast mobile position */
    .toast-container {
        top: auto !important;
        bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom, 0px)) !important;
        right: 16px !important;
        left: 16px !important;
    }

    .custom-toast {
        min-width: auto;
        width: 100%;
    }

    /* Form controls — prevent iOS zoom */
    .form-control, .form-select {
        font-size: 16px;
    }

    /* Sidebar footer compact */
    .sidebar-footer {
        padding: 12px 16px;
    }

    /* Button group horizontal scroll */
    .btn-group {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .btn-group::-webkit-scrollbar {
        display: none;
    }

    .btn-group .btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 4px 10px;
    }

    /* Dropdown menu */
    .dropdown-menu {
        width: 100%;
        min-width: auto;
    }
}

/* ========== RESPONSIVE — SMALL PHONES ========== */
@media (max-width: 380px) {
    .page-content {
        padding: 12px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .stat-value {
        font-size: 20px;
    }

    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        margin-bottom: 10px;
    }

    .topbar {
        padding: 8px 12px;
    }

    .topbar-left h4 {
        font-size: 14px;
    }
}

/* ========== ANIMATIONS ========== */
.fade-in {
    animation: fadeIn 0.35s ease-out;
}

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

/* Staggered animation for cards */
.stagger-in > * {
    opacity: 0;
    animation: fadeIn 0.35s ease-out forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }

/* ========== LOADING ========== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 46, 99, 0.2);
    border-left: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Shimmer loading effect */
.shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        rgba(255, 255, 255, 0.05) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

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

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.custom-toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    animation: slideInRight 0.35s ease-out;
    min-width: 300px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

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

/* ========== UTILITY CLASSES ========== */
.text-hint {
    color: var(--text-hint) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.gap-responsive {
    gap: 16px;
}

/* Hide on mobile / show on mobile helpers */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    .gap-responsive {
        gap: 10px;
    }
}

@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* ========== GLASSMORPHISM CARD ========== */
.glass-card {
    background: rgba(28, 28, 28, 0.65);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
}

/* ========== TABLE CARD MOBILE PADDING ========== */
@media (max-width: 768px) {
    .table-card {
        padding: 14px;
        border-radius: var(--radius-sm);
    }

    .table-card h5 {
        font-size: 15px;
    }

    .table-card h6 {
        font-size: 13px;
    }

    /* Toolbar full-width on mobile */
    .d-flex.flex-column.flex-md-row {
        width: 100%;
    }

    /* Cards in mobile-card-list full width */
    .mobile-data-card {
        width: 100%;
        overflow: hidden;
    }

    .mobile-data-card code {
        word-break: break-all;
    }

    /* Buttons in card-actions don't overflow */
    .mobile-data-card .card-actions {
        flex-wrap: wrap;
    }

    .mobile-data-card .card-meta {
        flex-wrap: wrap;
    }

    .mobile-data-card .card-meta > div {
        flex: 1 1 45%;
        min-width: 0;
    }
}

/* ========== PULL INDICATOR ========== */
.pull-indicator {
    text-align: center;
    padding: 8px;
    color: var(--text-hint);
    font-size: 12px;
    display: none;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    color: var(--text-hint);
    margin-bottom: 14px;
    display: block;
    opacity: 0.6;
}

.empty-state p {
    font-size: 14px;
    margin: 0;
}
