/* --- 1. GLOBAL CSS (FIX RESPONSIVE) --- */
html,
body {
    background: #f1f5f9;
    font-family: 'Segoe UI', sans-serif;
    font-size: 14px;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
}

img {
    max-width: 100%;
    height: auto;
}

.view-section {
    display: none !important;
    width: 100%;
    min-height: 100vh;
}

.view-active {
    display: block !important;
    animation: fadeIn 0.4s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

/* --- 2. SIDEBAR & CONTENT LAYOUT --- */
.sidebar {
    width: 260px;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
    background: #0f172a;
    color: white;
    padding: 20px;
    z-index: 1050;
    /* Di atas konten */
    transition: transform 0.3s ease-in-out;
    transform: translateX(0);
    /* Default Desktop: Muncul */
}

.content {
    margin-left: 260px;
    padding: 20px;
    transition: margin-left 0.3s ease-in-out;
    width: auto;
    /* Biarkan browser hitung sisanya */
}

/* Overlay Hitam saat menu di HP terbuka */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block !important;
}

/* --- 3. LOGIKA KHUSUS HP / TABLET (< 768px) --- */
@media(max-width:768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    /* Sembunyi ke kiri */
    .sidebar.show {
        transform: translateX(0);
    }

    /* Muncul jika tombol menu diklik */

    .content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
}

/* --- 4. LOGIKA KHUSUS HP KECIL (< 480px) --- */
/* Agar Live Count tidak berantakan di HP kecil */
@media(max-width:480px) {
    .race-card {
        flex-direction: column !important;
        text-align: center;
    }

    .race-card .d-flex {
        justify-content: center;
        width: 100%;
    }

    .cand-thumb {
        width: 80px;
        height: 80px;
        margin-bottom: 10px;
    }

    .rank-1 {
        transform: scale(1) !important;
    }

    /* Matikan zoom efek di hp kecil biar rapi */
}

/* --- KOMPONEN LAIN --- */
.nav-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
    transition: 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.card-box {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

/* Agar Login Card pas di tengah HP */
#v-login .card-box {
    width: 90%;
    max-width: 400px;
    margin: auto;
}

/* LOADER */
#loader {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.98);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#error-box {
    display: none;
    margin-top: 20px;
    color: #dc3545;
    font-weight: bold;
    border: 1px solid #dc3545;
    padding: 15px;
    border-radius: 8px;
    background: #fff;
    text-align: center;
}

/* LIVE COUNT STYLE */
.live-header {
    background: #1e293b;
    padding: 20px;
    color: white;
    border-bottom: 4px solid #f59e0b;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

.race-card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    transition: 0.5s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid white;
    position: relative;
    justify-content: space-between;
}

.rank-1 {
    background: linear-gradient(to right, #fffbeb, #fff);
    border: 2px solid #fbbf24;
    transform: scale(1.02);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.text-gold {
    color: #fbbf24 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.text-silver {
    color: #94a3b8 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cand-thumb {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #eee;
    flex-shrink: 0;
}

.img-dummy {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-weight: bold;
    transition: 0.2s;
}

.cand-admin-img {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    background: #eee;
    flex-shrink: 0;
}

#live-final {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    display: none;
}

#btn-scroll-top {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 900;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: 0.3s;
}

#btn-scroll-top:active {
    transform: scale(0.9);
}

.live-footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    bottom: 80px;
    margin-top: 30px;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.blink-red {
    animation: blinker 1.5s linear infinite;
    color: #dc3545;
    font-weight: bold;
}

@keyframes blinker {
    50% {
        opacity: 0.5;
    }
}

.eye-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #6c757d;
    z-index: 10;
}

.form-floating .eye-icon {
    top: 50%;
}

.modal-backdrop {
    z-index: 1050;
}

.modal {
    z-index: 1060;
}

#mCrop {
    z-index: 1070 !important;
}