/**
 * VOD 24/7 - Compact Design System (Enhanced)
 */

/* ========== CSS VARIABLES ========== */
:root {
    /* Colors - More vibrant & Premium */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.12);
    --primary-text: #1d4ed8;

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.12);

    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.12);

    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);

    /* Light theme */
    --bg-body: #f8fafc;
    /* Lighter, cooler gray */
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-hover: #e2e8f0;

    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    --border: #e2e8f0;

    /* Sizing */
    --sidebar-width: 240px;
    --header-height: 60px;
    --bottom-nav-height: 60px;
    --radius: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

    /* Transitions */
    --trans-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --trans-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-hover: #334155;

    --primary-light: rgba(59, 130, 246, 0.2);
    --primary-text: #60a5fa;

    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --border: #334155;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

/* ========== RESET & BASE ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color var(--trans-base), color var(--trans-base);
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--trans-fast);
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* ========== LAYOUT ========== */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

.app {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    /* Higher than bottom nav */
    transition: transform var(--trans-base), width var(--trans-base);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--header-height);
    padding: 0 1.25rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.025em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.875rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--trans-fast);
    border: 1px solid transparent;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text);
    transform: translateX(2px);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary-text);
    font-weight: 600;
}

.nav-link svg {
    opacity: 0.8;
}

.nav-link.active svg {
    opacity: 1;
}

/* Main Content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
    transition: margin-left var(--trans-base);
}

/* Header */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 50;
    transition: background-color var(--trans-base);
}

[data-theme="dark"] .header {
    background: rgba(30, 41, 59, 0.8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: background-color var(--trans-fast);
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

.brand-mobile {
    display: none;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: all var(--trans-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    transform: rotate(15deg);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 99px;
    transition: background-color var(--trans-fast);
}

.user-badge:hover {
    background: var(--bg-surface-hover);
}

.avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.username {
    font-weight: 500;
    color: var(--text);
}

/* Content Area */
.content {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 100%;
    overflow-x: hidden;
    animation: fadeIn 0.4s ease-out forwards;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 150;
    /* Between bottom nav and sidebar */
    opacity: 0;
    transition: opacity var(--trans-fast);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* Bottom Nav (Mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.5rem 0;
    text-decoration: none;
    transition: color var(--trans-fast);
}

.bottom-nav-item svg {
    width: 1.75rem;
    height: 1.75rem;
    transition: transform var(--trans-fast);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active svg {
    transform: translateY(-2px);
}

/* ========== COMPONENTS ========== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.025em;
    color: var(--text);
}

.page-desc {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--trans-fast), box-shadow var(--trans-fast);
}

.stats-bar:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-value.success {
    color: var(--success);
}

.stat-value.danger {
    color: var(--danger);
}

.stat-value.warning {
    color: var(--warning);
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--trans-base);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1.25rem;
}

/* Tables */
.table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-surface-hover);
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    transition: background-color var(--trans-fast);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-surface-hover);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--trans-fast);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    transition: all var(--trans-fast);
    box-shadow: var(--shadow-sm);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-muted {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* Dropdowns */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 0.375rem;
    animation: fadeIn 0.15s ease-out;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: background-color var(--trans-fast);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

/* Alerts & Toasts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 999;
    min-width: 300px;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-success {
    background: var(--success);
    color: white;
}

.toast-danger {
    background: var(--danger);
    color: white;
}

/* Empty State */
.empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty svg {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.3;
    color: var(--primary);
}

.empty-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* Utilities */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: 0.5rem;
}

.gap-2 {
    gap: 1rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-right {
    text-align: right;
}

th.hide-mobile,
td.hide-mobile {
    display: table-cell;
}

/* Table Wrapper for Horizontal Scroll */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-wrap table {
    min-width: 100%;
}

/* ========== LOGIN PAGE (PREMIUM) ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.15;
    z-index: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 380px;
    position: relative;
    z-index: 10;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.5s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    color: white;
}

.login-logo svg {
    width: 30px;
    height: 30px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.login-subtitle {
    color: #94a3b8;
    font-size: 0.9375rem;
}

.login-form .form-label {
    color: #e2e8f0;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.login-form .form-input {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.login-form .form-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: none;
}

.btn-login {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 0.9375rem;
    transition: all 0.2s;
    margin-top: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    color: #64748b;
    font-size: 0.8125rem;
}

/* ========== MOBILE ========== */
@media (max-width: 768px) {
    html {
        font-size: 18px;
        /* Keep readable size */
    }

    .sidebar {
        transform: translateX(-100%);
        visibility: hidden;
        /* Ensure it's hidden */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        box-shadow: var(--shadow-xl);
    }

    /* Hide redundant nav links in sidebar on mobile (since we have bottom nav) */
    /* .sidebar.open .sidebar-nav {
        display: none;
    } REVERTED: User wants sidebar nav */

    /* Ensure footer (logout) stays visible and pushed to bottom if needed */
    .sidebar.open .sidebar-footer {
        margin-top: auto;
    }

    .main {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }

    .bottom-nav {
        display: none !important;
    }

    .brand-mobile {
        display: block;
    }

    .username {
        display: none;
    }

    /* .bottom-nav {
        display: flex;
    } REMOVED */

    .content {
        padding: 1rem;
        /* padding-bottom: calc(var(--bottom-nav-height) + 1.5rem); REMOVED */
    }

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: calc(var(--bottom-nav-height) + 1rem);
        min-width: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .hide-mobile {
        display: none;
    }

    .stats-bar {
        padding: 1rem;
        gap: 1rem;
    }
}