/* =============================================
   RafflePro – Custom App Styles
   Design System: DESIGN.md
   ============================================= */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ---- CSS Variables (Design Tokens) ---- */
:root {
    /* Surface */
    --surface: #f8f9ff;
    --surface-dim: #cbdbf5;
    --surface-bright: #f8f9ff;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #eff4ff;
    --surface-container: #e5eeff;
    --surface-container-high: #dce9ff;
    --surface-container-highest: #d3e4fe;
    --on-surface: #0b1c30;
    --on-surface-variant: #4d4635;
    --inverse-surface: #213145;
    --inverse-on-surface: #eaf1ff;

    /* Outlines */
    --outline: #7f7663;
    --outline-variant: #d0c5af;

    /* Primary (Gold) */
    --primary: #735c00;
    --on-primary: #ffffff;
    --primary-container: #d4af37;
    --on-primary-container: #554300;
    --inverse-primary: #e9c349;
    --primary-fixed: #ffe088;
    --primary-fixed-dim: #e9c349;

    /* Secondary (Indigo) */
    --secondary: #4c56af;
    --on-secondary: #ffffff;
    --secondary-container: #959efd;
    --on-secondary-container: #27308a;

    /* Tertiary (Green) */
    --tertiary: #1b6d24;
    --on-tertiary: #ffffff;
    --tertiary-container: #74c570;
    --on-tertiary-container: #005111;

    /* Error */
    --error: #ba1a1a;
    --on-error: #ffffff;
    --error-container: #ffdad6;
    --on-error-container: #93000a;

    /* Background */
    --background: #f8f9ff;
    --on-background: #0b1c30;

    /* Live Draw Dark */
    --live-bg: #0F172A;
    --live-bg-2: #1e293b;
    --gold: #D4AF37;
    --gold-light: #FDE047;
    --gold-dim: #b89a2a;
}

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

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.5s ease, color 0.3s ease;
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes pulse-gold {
    0%   { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7); }
    70%  { box-shadow: 0 0 0 24px rgba(212, 175, 55, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.4) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

@keyframes starFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.4; }
    50%       { transform: translateY(-20px) rotate(180deg); opacity: 1; }
}

@keyframes glow-border {
    0%, 100% { box-shadow: 0 0 20px rgba(212, 175, 55, 0.4), inset 0 0 20px rgba(212, 175, 55, 0.05); }
    50%       { box-shadow: 0 0 50px rgba(212, 175, 55, 0.8), inset 0 0 30px rgba(212, 175, 55, 0.1); }
}

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

@keyframes dart-shake-anim {
    0%   { transform: translate(0, 0) rotate(0deg); }
    15%  { transform: translate(-7px, -5px) rotate(-1.5deg); }
    30%  { transform: translate(6px,  4px) rotate(1deg); }
    45%  { transform: translate(-4px, -2px) rotate(-0.5deg); }
    60%  { transform: translate(3px,  2px) rotate(0.4deg); }
    80%  { transform: translate(-2px, -1px) rotate(-0.2deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes impact-ring-expand {
    0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(3.5); opacity: 0; }
}

/* JS-toggled camera shake on roulette scene */
.dart-shake {
    animation: dart-shake-anim 0.35s ease-out forwards !important;
}

/* 3D Roulette scene perspective */
#roulette-scene {
    transform-style: preserve-3d;
}
#roulette-canvas {
    transform: rotateX(22deg) scale(1);
    transition: transform 0.8s ease;
}
#roulette-rim {
    transform: rotateX(22deg);
    pointer-events: none;
}

@keyframes orbPulse {
    0%   { transform: scale(0.95); box-shadow: 0 0 30px rgba(212,175,55,0.6), inset 0 0 20px rgba(255,255,255,0.4); }
    100% { transform: scale(1.05); box-shadow: 0 0 60px rgba(212,175,55,1), inset 0 0 40px rgba(255,255,255,0.8); }
}

@keyframes haloSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes scanline {
    0%   { top: -10%; }
    100% { top: 110%; }
}

/* =============================================
   LIVE DRAW – THEATRICAL DARK MODE
   ============================================= */

#view-live {
    background: var(--live-bg);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Particle background overlay */
#view-live::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(76, 86, 175, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(212, 175, 55, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.live-draw-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% auto;
    animation: shimmer 3s linear infinite;
}

.live-subtitle {
    color: rgba(234, 241, 255, 0.6);
    font-size: 1.125rem;
    font-weight: 400;
}

/* Control Panel – Glass morphism */
.live-control-panel {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
}

.live-control-panel label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.live-control-panel select,
.live-control-panel input[type="number"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    color: #eaf1ff;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.live-control-panel select:focus,
.live-control-panel input[type="number"]:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.live-control-panel select option {
    background: #1e293b;
    color: #eaf1ff;
}

/* Draw Button – Hero Component */
.btn-draw {
    background: linear-gradient(135deg, var(--gold), var(--gold-light) 50%, var(--gold));
    background-size: 200% auto;
    color: #241a00;
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    border-radius: 16px;
    padding: 1.25rem 3rem;
    min-height: 80px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    animation: pulse-gold 2s infinite;
    position: relative;
    overflow: hidden;
}

.btn-draw::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.btn-draw:hover::after {
    transform: translateX(100%);
}

.btn-draw:hover {
    background-position: right center;
    transform: translateY(-3px);
    box-shadow: 0 20px 40px rgba(212, 175, 55, 0.4);
}

.btn-draw:active {
    transform: translateY(0) scale(0.98);
}

.btn-draw:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
    transform: none !important;
}

.btn-draw .material-symbols-outlined {
    font-size: 2rem;
}

/* Result Box */
.result-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid var(--gold);
    border-radius: 20px;
    min-height: 180px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: opacity 0.4s ease;
}

.result-box.active {
    animation: glow-border 2s ease-in-out infinite;
}

.shuffle-text {
    font-family: 'Courier New', monospace;
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--gold-light);
    text-align: center;
    text-shadow: 0 0 20px rgba(253, 224, 71, 0.5);
}

.winner-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--secondary-container);
    margin-bottom: 8px;
}

.winner-name {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 900;
    color: #ffffff;
    text-align: center;
    line-height: 1.1;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.winner-sub {
    font-size: 1rem;
    color: rgba(234, 241, 255, 0.7);
    margin-top: 6px;
    text-align: center;
}

/* Multi winner cards */
.winner-card {
    background: rgba(212, 175, 55, 0.07);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 12px 20px;
}

/* Mass draw cards – JS animates them in */
.mass-card {
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.mass-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 32px rgba(212,175,55,0.25);
}

/* Multi winner grid responsive */
#multi-winner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    width: 100%;
}

/* =============================================
   TOP NAV BAR
   ============================================= */

#top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: all 0.4s ease;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.15);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    color: rgba(234, 241, 255, 0.7);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
    color: #eaf1ff;
}

.btn-mode-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 99px;
    border: none;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-light);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.btn-mode-toggle:hover {
    background: rgba(212, 175, 55, 0.25);
}

/* =============================================
   ADMIN PANEL
   ============================================= */

#view-admin {
    background: var(--background);
    min-height: 100vh;
    display: flex;
}

/* Sidebar */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 70px;
    bottom: 0;
    width: 260px;
    background: var(--surface-container-lowest);
    border-right: 1px solid var(--outline-variant);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 16px;
}

.sidebar-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--on-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--secondary);
}

.sidebar-user-role {
    font-size: 0.7rem;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-new-raffle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: var(--secondary);
    color: var(--on-secondary);
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.btn-new-raffle:hover {
    background: #3a4498;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 86, 175, 0.3);
}

.sidebar-nav { flex: 1; }

.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--on-surface-variant);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.sidebar-nav-item:hover {
    background: var(--surface-container);
    color: var(--secondary);
}

.sidebar-nav-item.active {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
    font-weight: 700;
}

.sidebar-nav-item .material-symbols-outlined {
    font-size: 1.25rem;
}

.sidebar-footer {
    border-top: 1px solid var(--outline-variant);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--error);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-logout:hover {
    background: var(--error-container);
}

/* Admin Content Area */
.admin-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    padding-top: calc(70px + 2rem);
    min-height: 100vh;
    overflow-y: auto;
}

/* Admin Panels */
.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* Page Header */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--on-background);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--on-surface-variant);
    margin-top: 4px;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.gold    { background: rgba(212, 175, 55, 0.15); color: var(--primary); }
.stat-icon.indigo  { background: rgba(76, 86, 175, 0.12); color: var(--secondary); }
.stat-icon.green   { background: rgba(27, 109, 36, 0.12);  color: var(--tertiary); }
.stat-icon.red     { background: rgba(186, 26, 26, 0.1);   color: var(--error); }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--on-background);
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Data Card */
.data-card {
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 8px;
    border: none;
    font-size: 0.8125rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--secondary);
    color: var(--on-secondary);
}
.btn-primary:hover { background: #3a4498; box-shadow: 0 4px 12px rgba(76,86,175,0.3); }

.btn-gold {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #241a00;
}
.btn-gold:hover { box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    color: var(--on-surface-variant);
    border: 1px solid var(--outline-variant);
}
.btn-outline:hover { background: var(--surface-container); }

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error-container);
}
.btn-danger:hover { background: var(--error-container); }

.btn-sm { padding: 5px 12px; font-size: 0.75rem; border-radius: 6px; }

.btn .material-symbols-outlined { font-size: 1rem; }

/* =============================================
   DATATABLES – Custom Styling
   ============================================= */

#hadiah-table_wrapper,
#peserta-table_wrapper {
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
}

table.dataTable thead th {
    background: var(--secondary) !important;
    color: var(--on-secondary) !important;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 16px;
    border: none !important;
}

table.dataTable thead th:first-child { border-radius: 8px 0 0 0 !important; }
table.dataTable thead th:last-child  { border-radius: 0 8px 0 0 !important; }

table.dataTable tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-container);
    color: var(--on-surface);
    vertical-align: middle;
}

table.dataTable tbody tr:hover td {
    background: var(--surface-container-low) !important;
}

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

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--outline-variant);
    border-radius: 8px;
    padding: 7px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: var(--on-surface);
    background: var(--surface-container-lowest);
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-left: 8px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(76, 86, 175, 0.15);
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    padding: 5px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    background: var(--surface-container-lowest);
    margin: 0 6px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    padding: 5px 10px !important;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.15s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--secondary) !important;
    color: white !important;
    border: 1px solid var(--secondary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-container-high) !important;
    color: var(--secondary) !important;
    border-color: var(--outline-variant) !important;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.8rem;
    color: var(--on-surface-variant);
}

/* =============================================
   STATUS BADGES
   ============================================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-winner {
    background: rgba(116, 197, 112, 0.2);
    color: var(--on-tertiary-container);
    border: 1px solid rgba(116, 197, 112, 0.4);
}

.badge-pending {
    background: var(--surface-container);
    color: var(--on-surface-variant);
    border: 1px solid var(--outline-variant);
}

.badge-active {
    background: rgba(76, 86, 175, 0.12);
    color: var(--secondary);
    border: 1px solid rgba(76, 86, 175, 0.3);
}

/* =============================================
   MODALS
   ============================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    /* Overlay container itself does NOT capture clicks; backdrop ::before does */
    pointer-events: none;
}

/* Dark backdrop layer — rendered BEHIND the dialog */
.modal-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: auto; /* backdrop IS clickable (triggers close) */
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* re-enable so backdrop ::before can fire events */
}

.modal-dialog {
    background: var(--surface-container-lowest);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.2s ease;
    /* CRITICAL: dialog must be above the ::before backdrop */
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

.modal-overlay.open .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--on-surface);
    margin-bottom: 20px;
}

/* Form Fields */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--on-surface-variant);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--outline-variant);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    color: var(--on-surface);
    background: var(--surface-container-lowest);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(76, 86, 175, 0.15);
}

.form-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%234d4635' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--outline-variant);
}

/* =============================================
   TOGGLE SWITCH
   ============================================= */

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--surface-dim);
    border-radius: 99px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: '';
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background: var(--secondary);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* =============================================
   SETTINGS PANEL
   ============================================= */

.settings-card {
    background: var(--surface-container-lowest);
    border: 1px solid var(--outline-variant);
    border-radius: 14px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    transition: background 0.15s;
}

.settings-card:hover {
    background: var(--surface-container-low);
}

.settings-card-info h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--on-surface);
}

.settings-card-info p {
    font-size: 0.8125rem;
    color: var(--on-surface-variant);
    margin-top: 2px;
}

/* =============================================
   LOG TABLE
   ============================================= */

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

.log-table thead th {
    background: var(--surface-container-low);
    color: var(--on-surface-variant);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 10px 14px;
    text-align: left;
}

.log-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--surface-container);
    font-size: 0.875rem;
    color: var(--on-surface);
}

.log-table tbody tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover td { background: var(--surface-container-low); }

/* =============================================
   EVENT TABLE
   ============================================= */

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

.event-table thead th {
    background: var(--secondary);
    color: var(--on-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 16px;
    text-align: left;
}

.event-table thead th:first-child { border-radius: 8px 0 0 0; }
.event-table thead th:last-child  { border-radius: 0 8px 0 0; }

.event-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-container);
    font-size: 0.875rem;
    color: var(--on-surface);
}

/* =============================================
   LOGIN PAGE
   ============================================= */

.login-page {
    min-height: 100vh;
    background: var(--live-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(76, 86, 175, 0.2) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 70%, rgba(212, 175, 55, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: 0 32px 80px rgba(0,0,0,0.4);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p {
    font-size: 0.875rem;
    color: rgba(234, 241, 255, 0.5);
    margin-top: 4px;
}

.login-form .form-label {
    color: rgba(234, 241, 255, 0.7);
}

.login-form .form-control {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.15);
    color: #eaf1ff;
}

.login-form .form-control::placeholder { color: rgba(234, 241, 255, 0.3); }

.login-form .form-control:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #241a00;
    border: none;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(212, 175, 55, 0.4);
}

.btn-login:active { transform: translateY(0); }

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 1024px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-content { margin-left: 0; }
}

@media (max-width: 768px) {
    .live-control-panel { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 2rem 1.5rem; }
    .btn-draw { padding: 1rem 2rem; min-height: 68px; font-size: 1rem; }
}
