/* ==========================================================================
   E-VOTING PILKADES DESA DARMAGA
   Custom Modern Styling, Print Rules & No-Scroll Ballot Engine
   Kecamatan Cisalak, Kabupaten Subang - Jawa Barat
   ========================================================================== */

/* --- 1. Base Variables & High Contrast --- */
:root {
    --brand-navy: #0f172a;
    --brand-navy-light: #1e293b;
    --brand-blue: #0369a1;
    --brand-teal: #0d9488;
    --brand-emerald: #059669;
    --brand-emerald-hover: #10b981;
}

/* Fallbacks for gradients */
.bg-gradient-navy {
    background-color: #0f172a;
    background-image: linear-gradient(135deg, #0f172a 0%, #0c4a6e 50%, #042f2e 100%);
}

.bg-gradient-emerald {
    background-color: #059669;
    background-image: linear-gradient(135deg, #059669 0%, #0d9488 100%);
}

/* ==========================================================================
   STRICT LOGO & IMAGE SIZING (Prevents Image Expansion Bug Across All Browsers)
   ========================================================================== */
.app-header-logo {
    height: 36px !important;
    max-height: 36px !important;
    width: auto !important;
    max-width: 48px !important;
    object-fit: contain !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

.voter-header-logo {
    height: 34px !important;
    max-height: 34px !important;
    width: auto !important;
    max-width: 44px !important;
    object-fit: contain !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

.login-logo {
    max-height: 58px !important;
    width: auto !important;
    max-width: 60px !important;
    object-fit: contain !important;
    display: inline-block !important;
}

/* Missing Sizing Utilities */
.max-w-full { max-width: 100% !important; }
.max-h-full { max-height: 100% !important; }
.min-h-0 { min-height: 0 !important; }
.min-w-0 { min-width: 0 !important; }
.w-auto { width: auto !important; }
.h-auto { height: auto !important; }
.h-7 { height: 1.75rem !important; }
.h-8 { height: 2rem !important; }
.h-9 { height: 2.25rem !important; }
.h-10 { height: 2.5rem !important; }
.h-11 { height: 2.75rem !important; }
.h-12 { height: 3rem !important; }
.w-7 { width: 1.75rem !important; }
.w-8 { width: 2rem !important; }
.w-9 { width: 2.25rem !important; }
.w-10 { width: 2.5rem !important; }
.w-11 { width: 2.75rem !important; }
.w-12 { width: 3rem !important; }
.max-h-\[20vh\] { max-height: 20vh !important; }
.max-h-\[22vh\] { max-height: 22vh !important; }
.max-h-\[24vh\] { max-height: 24vh !important; }

/* High Contrast Button Utilities */
.btn-primary {
    background-color: #0284c7 !important;
    background-image: linear-gradient(to right, #0284c7, #0d9488) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    border: none !important;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.btn-primary:hover {
    background-image: linear-gradient(to right, #0369a1, #0f766e) !important;
    box-shadow: 0 10px 15px -3px rgba(2, 132, 199, 0.4);
}

.btn-emerald {
    background-color: #059669 !important;
    background-image: linear-gradient(to right, #059669, #10b981) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    border: none !important;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}
.btn-emerald:hover {
    background-color: #047857 !important;
    background-image: linear-gradient(to right, #047857, #059669) !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -3px rgba(16, 185, 129, 0.4);
}
.btn-emerald:active {
    transform: scale(0.98);
}

/* --- 2. Bilik Suara No-Scroll 100vh Viewport --- */
.ballot-screen {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #090d16;
    color: #f8fafc;
}

.ballot-header {
    flex-shrink: 0;
    padding: 0.5rem 1.5rem;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
}

.ballot-title-banner {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    text-align: center;
}

.ballot-candidates-container {
    flex: 1;
    min-height: 0; /* Critical for nested flex scrolling avoidance */
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 1.25rem;
    padding: 0.5rem 1.5rem 1rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.ballot-candidate-card {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 3px solid #334155;
    border-radius: 1.25rem;
    padding: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ballot-candidate-card:hover {
    border-color: #38bdf8;
    transform: translateY(-4px);
    box-shadow: 0 25px 35px -5px rgba(56, 189, 248, 0.25);
}

.ballot-candidate-card.active-choice {
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.4);
}

.ballot-candidate-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(51, 65, 85, 0.6);
}

.ballot-number-badge {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 0.875rem;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    font-size: 1.875rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ballot-photo-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
}

.ballot-candidate-img {
    max-height: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    border: 3px solid #334155;
    background-color: #090d16;
}

.ballot-candidate-info {
    flex-shrink: 0;
    text-align: center;
    padding-top: 0.375rem;
}

.ballot-candidate-name {
    font-size: 1.125rem;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.25;
}

.ballot-candidate-address {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.125rem;
}

.ballot-candidate-action {
    flex-shrink: 0;
    padding-top: 0.75rem;
}

.ballot-vote-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    font-size: 1.125rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ballot-footer {
    flex-shrink: 0;
    padding: 0.375rem 1.5rem;
    background-color: #020617;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
}

/* --- 3. Barcode Scanner Styling --- */
.barcode-scan-box {
    position: relative;
    border: 2px dashed #0284c7;
    border-radius: 1.25rem;
    background: rgba(2, 132, 199, 0.05);
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s ease;
}

.barcode-scan-box:focus-within {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.barcode-beam {
    height: 3px;
    background: linear-gradient(90deg, transparent, #38bdf8, #10b981, transparent);
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    z-index: 10;
    pointer-events: none;
    animation: barcodeLaser 2.2s infinite ease-in-out;
    box-shadow: 0 0 10px #38bdf8, 0 0 5px #10b981;
}

@keyframes barcodeLaser {
    0%, 100% { top: 15%; opacity: 0.3; }
    50% { top: 85%; opacity: 1; }
}

/* ==========================================================================
   TERMINAL BILIK SUARA: Centered Hero Scanner (Murni Barcode Bebas Scroll)
   ========================================================================== */
.terminal-layout-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .terminal-layout-wrapper {
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }
}

.terminal-hero-scanner {
    width: 100%;
    max-width: 1040px;
    margin: auto;
    display: grid !important;
    grid-template-columns: 1.15fr 1fr;
    gap: 1rem;
    align-items: stretch;
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: 84vh;
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid rgba(56, 189, 248, 0.4);
    border-radius: 1.5rem;
    padding: 0.85rem 1.15rem;
    box-sizing: border-box;
    box-shadow: 0 25px 35px -5px rgba(0, 0, 0, 0.6), 0 0 25px rgba(2, 132, 199, 0.15);
    overflow: hidden;
}

.terminal-split-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    align-items: stretch;
    box-sizing: border-box;
    overflow: hidden;
}

.terminal-camera-col {
    flex: 1 1 0% !important;
    min-width: 0;
    height: 100%;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.94);
    border: 2px solid rgba(51, 65, 85, 0.85);
    border-radius: 1.25rem;
    padding: 0.75rem 1rem;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .terminal-split-row {
        flex-direction: column !important;
        overflow-y: auto !important;
    }
    .terminal-camera-col, .terminal-keypad-col {
        flex: none !important;
        height: auto;
    }
}

/* Scanner Camera Viewport & HUD Elements (Proporsional & Bebas Potongan) */
#qrReader {
    position: relative;
    background: #020617;
    border-radius: 1rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    height: 100% !important;
    min-height: 180px;
}

/* Video kamera: Menampilkan 100% frame kamera utuh tanpa pemotongan gambar (aspect ratio murni) */
#qrReader video,
#operatorQrReader video {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border-radius: 0.875rem;
    display: block !important;
    /* CEGAH DIRECTCOMPOSITION HARDWARE OVERLAY BYPASS SAAT FULLSCREEN */
    transform: translateZ(0) !important;
    will-change: transform !important;
    filter: opacity(0.999) !important;
    backface-visibility: hidden !important;
}

/* Elemen internal scan region dari library html5-qrcode
   PENTING: JANGAN menyembunyikan canvas/img di sini karena library 
   membutuhkannya untuk membaca frame video dan mendecodingnya via ZXing */
#qrReader__scan_region {
    background: transparent !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Dashboard control bawaan library - SEMBUNYIKAN */
#qrReader__dashboard,
#qrReader__dashboard_section,
#qrReader__dashboard_section_csr,
#qrReader__dashboard_section_swaplink {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Header message & shaded region bawaan library */
#qrReader__header_message,
#qr-shaded-region {
    display: none !important;
}

/* Kotak Bidik Pemindai Barcode (Centered Viewfinder Target Box) */
.scanner-target-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(180px, 32vw, 240px);
    height: clamp(180px, 32vw, 240px);
    max-width: 80%;
    max-height: 80%;
    aspect-ratio: 1 / 1;
    border: 2px dashed rgba(56, 189, 248, 0.85);
    border-radius: 18px;
    pointer-events: none;
    z-index: 15;
    box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.52);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.scanner-guide-badge {
    position: relative;
    z-index: 10;
    max-width: 95%;
    padding: 3px 10px;
    border-radius: 9999px;
    font-weight: 800;
    letter-spacing: 0.025em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    user-select: none;
}
.scanner-guide-badge.top {
    background: rgba(2, 6, 23, 0.9);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.6);
    font-size: clamp(9px, 1.4vw, 11px);
}
.scanner-guide-badge.bottom {
    background: rgba(2, 6, 23, 0.9);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.6);
    font-size: clamp(8.5px, 1.3vw, 10.5px);
}

.scanner-target-box.active-scan {
    border-color: #10b981;
    box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.42), 0 0 20px rgba(16, 185, 129, 0.5);
}

/* Sudut HUD Pemindai (Identik Meja Verifikasi & Bilik Suara) */
.scanner-hud-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    pointer-events: none;
    z-index: 10;
}
.scanner-hud-corner.top-left {
    top: 10px;
    left: 10px;
    border-top: 4px solid #38bdf8;
    border-left: 4px solid #38bdf8;
    border-top-left-radius: 12px;
}
.scanner-hud-corner.top-right {
    top: 10px;
    right: 10px;
    border-top: 4px solid #38bdf8;
    border-right: 4px solid #38bdf8;
    border-top-right-radius: 12px;
}
.scanner-hud-corner.bottom-left {
    bottom: 10px;
    left: 10px;
    border-bottom: 4px solid #38bdf8;
    border-left: 4px solid #38bdf8;
    border-bottom-left-radius: 12px;
}
.scanner-hud-corner.bottom-right {
    bottom: 10px;
    right: 10px;
    border-bottom: 4px solid #38bdf8;
    border-right: 4px solid #38bdf8;
    border-bottom-right-radius: 12px;
}

/* 4 Sudut Presisi Kotak Bidik */
.target-corner {
    position: absolute;
    width: 26px;
    height: 26px;
    pointer-events: none;
}
.target-corner.top-left {
    top: -2px;
    left: -2px;
    border-top: 4px solid #38bdf8;
    border-left: 4px solid #38bdf8;
    border-top-left-radius: 14px;
}
.target-corner.top-right {
    top: -2px;
    right: -2px;
    border-top: 4px solid #38bdf8;
    border-right: 4px solid #38bdf8;
    border-top-right-radius: 14px;
}
.target-corner.bottom-left {
    bottom: -2px;
    left: -2px;
    border-bottom: 4px solid #38bdf8;
    border-left: 4px solid #38bdf8;
    border-bottom-left-radius: 14px;
}
.target-corner.bottom-right {
    bottom: -2px;
    right: -2px;
    border-bottom: 4px solid #38bdf8;
    border-right: 4px solid #38bdf8;
    border-bottom-right-radius: 14px;
}

/* Animasi Sinar Laser Pemindai di Dalam Kotak Bidik */
.scanner-target-laser {
    position: absolute;
    left: 4px;
    right: 4px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #38bdf8, #10b981, #38bdf8, transparent);
    box-shadow: 0 0 12px #38bdf8, 0 0 6px #10b981;
    border-radius: 50%;
    animation: targetLaserMotion 2s ease-in-out infinite alternate;
}

@keyframes targetLaserMotion {
    0% { top: 6%; opacity: 0.85; }
    50% { opacity: 1; }
    100% { top: 92%; opacity: 0.85; }
}

/* Struk Fisik Bukti Suara Kotak Suara: Format 1/4 Kertas A4 (A6) & Posisi di Pojok Kiri Atas (Tidak di Tengah) */
@media print {
    @page {
        size: A4 portrait;
        margin: 5mm;
    }
    html, body {
        background: #ffffff !important;
        color: #000000 !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    header, footer, nav, .no-print {
        display: none !important;
    }
    #auditReceiptSlip, #auditReceiptSlip * {
        visibility: visible !important;
    }
    #auditReceiptSlip {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        margin: 0 !important; /* Posisi di pojok kiri atas (TIDAK DI TENGAH) */
        display: block !important;
        width: 96mm !important;
        max-width: 98mm !important;
        min-height: 128mm !important;
        max-height: 140mm !important;
        padding: 4mm 5mm !important;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: 1.5px dashed #000000 !important;
        border-radius: 6px !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        box-sizing: border-box !important;
    }
}

/* --- 4. Surat Undangan Pemilih (Model C6 Digital) Stylesheet --- */
.invitation-page {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
    page-break-after: always;
}

.invitation-card {
    border: 1.5px dashed #475569;
    border-radius: 10px;
    padding: 8px 12px;
    background-color: #ffffff;
    color: #0f172a;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

@media print {
    .invitation-page {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .invitation-card {
        border: 1px dashed #64748b !important;
        box-shadow: none !important;
    }
}

/* ==========================================================================
   5. Modern Responsive Split-Screen Login & Poster Layout
   ========================================================================== */
.login-body-bg {
    min-height: 100vh;
    background: radial-gradient(circle at top right, #0f2b48 0%, #071322 45%, #050d18 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1rem;
    box-sizing: border-box;
}

.login-split-wrapper {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    box-sizing: border-box;
}

.login-side-form {
    flex: 0 0 420px;
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-side-poster {
    flex: 1 1 500px;
    max-width: 540px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.login-glass-card {
    background: #ffffff;
    border-radius: 1.25rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15);
    padding: 1.5rem 1.75rem;
    color: #1e293b;
}

.poster-glass-card {
    position: relative;
    width: 100%;
    background: rgba(13, 22, 38, 0.8);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(56, 189, 248, 0.22);
    border-radius: 1.5rem;
    padding: 0.85rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 25px rgba(14, 165, 233, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

.poster-media-container {
    position: relative;
    width: 100%;
    height: 470px;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 9, 16, 0.6);
    border-radius: 1rem;
    overflow: hidden;
}

.poster-img-fit {
    max-height: 450px;
    max-width: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

@media (max-width: 920px) {
    .login-split-wrapper {
        flex-direction: column;
        gap: 1.5rem;
    }
    .login-side-form, .login-side-poster {
        flex: none;
        max-width: 440px;
        width: 100%;
    }
    .poster-media-container {
        height: 380px;
    }
    .poster-img-fit {
        max-height: 360px;
    }
}

/* ==========================================================================
   LANDSCAPE & FULLSCREEN KIOSK ENGINE (SMARTPHONE, TABLET & KIOSK TERMINAL)
   Zero-Scroll, 100% Viewport-Fit, Proporsional di Seluruh Orientasi & Device
   ========================================================================== */

/* 0. Body & Shell Kiosk */
body.voter-kiosk-body {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    touch-action: manipulation;
}

/* 1. Header & Footer Kiosk Ultra-Ringkas di Smartphone */
@media (max-height: 520px), (max-width: 639px) {
    .voter-kiosk-header {
        padding: 0.2rem 0.5rem !important;
    }
    .voter-kiosk-header img {
        height: 1.25rem !important;
        max-height: 1.25rem !important;
        max-width: 1.5rem !important;
    }
    .voter-kiosk-footer {
        padding: 0.15rem 0.5rem !important;
        font-size: 0.65rem !important;
        line-height: 1.1 !important;
    }
}

/* 2. Wrapper Surat Suara (Ballot) Proporsional */
.ballot-screen-wrapper {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.ballot-instruction-banner {
    flex-shrink: 0;
    padding: 0.25rem 0.6rem;
    border-radius: 0.75rem;
    margin-bottom: 0.25rem;
}

/* Tampilan Landscape di Semua Perangkat & Layar Lebar (Tablet/Desktop/Kiosk): 
   Seluruh calon berjajar ke samping (3 kolom), 100% pas 1 layar tanpa scroll */
@media (min-width: 640px), (orientation: landscape) {
    .ballot-candidates-grid {
        display: grid !important;
        grid-template-columns: repeat(var(--candidates-cols, 3), minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        align-items: stretch !important;
        margin-bottom: 0.25rem !important;
    }
    .ballot-candidate-card {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        padding: 0.4rem 0.6rem !important;
        border-radius: 1rem !important;
    }
    .ballot-candidate-card .card-photo-wrapper {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
        margin: 0.25rem 0 !important;
    }
    .ballot-candidate-card .ballot-photo-box {
        height: clamp(100px, 32vh, 280px) !important;
        max-height: 38vh !important;
        max-width: 100% !important;
        border-radius: 0.85rem !important;
    }
    .ballot-candidate-card .ballot-vote-button {
        min-height: 32px !important;
        padding: 0.4rem 0.6rem !important;
        font-size: clamp(0.75rem, 1.8vw, 0.9rem) !important;
    }
}

/* Tampilan Portrait di Smartphone (< 640px portrait):
   Seluruh calon disajikan proporsional dalam strip horizontal berjajar rapi 
   100% PAS 1 LAYAR TANPA SCROLL SAMA SEKALI */
@media (max-width: 639px) and (orientation: portrait) {
    .ballot-screen-wrapper {
        padding: 0.25rem 0.4rem !important;
    }
    .ballot-instruction-banner {
        padding: 0.25rem 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    .ballot-candidates-grid {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        gap: 0.35rem !important;
        justify-content: space-evenly !important;
        margin: 0 0 0.25rem 0 !important;
    }
    .ballot-candidate-card {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        max-height: 28vh !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0.3rem 0.5rem !important;
        gap: 0.45rem !important;
        border-radius: 0.85rem !important;
        border-width: 2px !important;
    }
    .ballot-candidate-card .card-header-bar {
        border-bottom: none !important;
        width: auto !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
    }
    .ballot-candidate-card .card-qr-box {
        display: none !important;
    }
    .ballot-candidate-card .card-nomor-badge {
        width: 32px !important;
        height: 32px !important;
        font-size: 1.15rem !important;
        font-weight: 900 !important;
        border-radius: 0.6rem !important;
    }
    .ballot-candidate-card .card-photo-wrapper {
        flex: none !important;
        width: 50px !important;
        height: 60px !important;
        margin: 0 !important;
        border-radius: 0.5rem !important;
        overflow: hidden !important;
    }
    .ballot-candidate-card .ballot-photo-box {
        width: 50px !important;
        height: 60px !important;
        max-height: 60px !important;
        border-radius: 0.5rem !important;
        padding: 1px !important;
    }
    .ballot-candidate-card .card-info-wrapper {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        text-align: left !important;
        padding: 0 0.2rem !important;
    }
    .ballot-candidate-card .card-nama-text {
        font-size: 0.82rem !important;
        font-weight: 900 !important;
        line-height: 1.15 !important;
        color: #ffffff !important;
    }
    .ballot-candidate-card .card-alamat-text {
        font-size: 0.68rem !important;
        color: #94a3b8 !important;
    }
    .ballot-candidate-card .card-visi-box {
        display: none !important;
    }
    .ballot-candidate-card .card-button-wrapper {
        flex: none !important;
        width: auto !important;
        padding: 0 !important;
    }
    .ballot-candidate-card .ballot-vote-button {
        padding: 0.45rem 0.65rem !important;
        font-size: 0.72rem !important;
        font-weight: 900 !important;
        border-radius: 0.65rem !important;
        white-space: nowrap !important;
        min-height: 34px !important;
    }
}

/* 3. Terminal Bilik Suara Layout (Centered Hero Scanner & Side Panel) */
.terminal-layout-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    height: 100% !important;
    max-height: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
}

/* Landscape Terminal di Smartphone / Tablet: 2-Kolom (Kamera di Kiri, Kontrol & Simulasi di Kanan) */
/* Landscape di Layar Kecil (Smartphone Landscape: max-height 520px): 
   2-Kolom Sejajar, Kamera di Kiri, Kontrol di Kanan, 100% Pas Bebas Scroll */
@media (orientation: landscape) and (max-height: 520px) {
    .terminal-layout-wrapper {
        padding: 0.2rem 0.5rem !important;
    }
    .terminal-hero-scanner {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        flex: 1 1 0% !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: 88vh !important;
        padding: 0.35rem 0.5rem !important;
        align-items: stretch !important;
        overflow: hidden !important;
    }
    #cameraScanViewport {
        height: 100% !important;
        min-height: 0 !important;
        max-height: 82vh !important;
        border-radius: 0.85rem !important;
    }
    .terminal-side-panel {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        height: 100% !important;
    }
    .scanner-target-box {
        width: clamp(125px, 48vh, 160px) !important;
        height: clamp(125px, 48vh, 160px) !important;
        padding: 5px !important;
        border-radius: 14px !important;
    }
    .scanner-guide-badge.top {
        font-size: 8.5px !important;
        padding: 2px 6px !important;
    }
    .scanner-guide-badge.bottom {
        font-size: 8px !important;
        padding: 2px 6px !important;
    }
    .scanner-watermark-qr svg {
        width: 24px !important;
        height: 24px !important;
    }
    .ballot-photo-box {
        height: clamp(80px, 20vh, 120px) !important;
        max-height: 22vh !important;
        border-radius: 0.5rem !important;
    }
    .ballot-candidate-card {
        padding: 0.25rem 0.4rem !important;
        border-radius: 0.75rem !important;
    }
    .ballot-vote-button {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.72rem !important;
        min-height: 26px !important;
    }
}

/* Portrait di Smartphone (< 768px portrait): Terpusat, Proporsional, Bebas Scroll */
@media (max-width: 767px) and (orientation: portrait) {
    .terminal-layout-wrapper {
        padding: 0.3rem 0.4rem !important;
    }
    .terminal-hero-scanner {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        gap: 0.45rem !important;
        padding: 0.5rem !important;
        max-height: 100% !important;
        border-radius: 1.25rem !important;
        overflow: hidden !important;
    }
    #cameraScanViewport {
        flex: 1 1 0% !important;
        min-height: 150px !important;
        max-height: 40vh !important;
        border-radius: 1rem !important;
    }
    .scanner-target-box {
        width: clamp(150px, 46vw, 195px) !important;
        height: clamp(150px, 46vw, 195px) !important;
        padding: 6px !important;
        border-radius: 16px !important;
    }
    .scanner-guide-badge.top {
        font-size: 9.5px !important;
        padding: 2px 8px !important;
    }
    .scanner-guide-badge.bottom {
        font-size: 9px !important;
        padding: 2px 8px !important;
    }
    .scanner-watermark-qr svg {
        width: 32px !important;
        height: 32px !important;
    }
    .terminal-side-panel {
        flex: 1 1 0% !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }
}

/* ==========================================================================
   TABLET, LAPTOP, PC & MONITOR BESAR: UKURAN FOTO CALON BESAR & TIDAK TERPOTONG
   ========================================================================== */

/* Foto Calon Murni Utuh, Tanpa Terpotong (Object-Contain) di Seluruh Layar */
.ballot-candidate-card .ballot-photo-box img {
    max-height: 100% !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    object-position: center center !important;
    border-radius: 0.75rem !important;
}

/* 1. Tablet Layar Sentuh (iPad / Android Tablet: min-width 768px & min-height 521px) */
@media (min-width: 768px) and (min-height: 521px) {
    .ballot-screen-wrapper {
        padding: 0.4rem 1rem !important;
    }
    .ballot-instruction-banner {
        padding: 0.4rem 0.85rem !important;
        margin-bottom: 0.4rem !important;
    }
    .ballot-candidates-grid {
        gap: 0.85rem !important;
        margin-bottom: 0.35rem !important;
    }
    .ballot-candidate-card {
        padding: 0.75rem 0.85rem !important;
        border-radius: 1.25rem !important;
    }
    .ballot-candidate-card .card-photo-wrapper {
        margin: 0.4rem 0 !important;
    }
    .ballot-candidate-card .ballot-photo-box {
        height: clamp(230px, 48vh, 390px) !important;
        max-height: 52vh !important;
        border-radius: 1rem !important;
    }
    .ballot-candidate-card .card-nama-text {
        font-size: 1.2rem !important;
        margin-top: 0.35rem !important;
    }
    .ballot-candidate-card .card-nomor-badge {
        width: 44px !important;
        height: 44px !important;
        font-size: 1.5rem !important;
    }
}

/* 2. Laptop & Desktop PC (1366x768 / 1080p: min-width 1024px & min-height 600px) */
@media (min-width: 1024px) and (min-height: 600px) {
    .ballot-screen-wrapper {
        max-width: 1400px !important;
        padding: 0.5rem 1.5rem !important;
    }
    .ballot-instruction-banner {
        padding: 0.5rem 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    .ballot-candidates-grid {
        gap: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }
    .ballot-candidate-card {
        padding: 1rem 1.25rem !important;
        border-radius: 1.5rem !important;
        border-width: 3px !important;
    }
    .ballot-candidate-card:hover {
        transform: translateY(-3px) scale(1.01);
    }
    .ballot-candidate-card .card-photo-wrapper {
        margin: 0.5rem 0 !important;
    }
    .ballot-candidate-card .ballot-photo-box {
        height: clamp(290px, 58vh, 540px) !important;
        max-height: 62vh !important;
        max-width: 100% !important;
        border-radius: 1.25rem !important;
        border-width: 3px !important;
    }
    .ballot-candidate-card .card-nama-text {
        font-size: 1.4rem !important;
        font-weight: 900 !important;
        margin-top: 0.5rem !important;
    }
    .ballot-candidate-card .card-nomor-badge {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.85rem !important;
        border-radius: 1rem !important;
    }
}

/* 3. Layar Monitor Lebar & Kiosk Display Besar (min-width: 1366px & min-height: 750px) */
@media (min-width: 1366px) and (min-height: 750px) {
    .ballot-candidate-card .ballot-photo-box {
        height: clamp(340px, 62vh, 600px) !important;
        max-height: 66vh !important;
    }
    .ballot-candidate-card .card-nama-text {
        font-size: 1.55rem !important;
    }
    .ballot-candidate-card .card-nomor-badge {
        width: 58px !important;
        height: 58px !important;
        font-size: 2.1rem !important;
        border-radius: 1.15rem !important;
    }
}

/* ==========================================================================
   FORM INPUT & CONTROLS STYLING (Admin, Panitia, Operator UI)
   Mengatasi kendala elemen input/select/textarea transparan/tanpa border bawaan Tailwind.
   Memastikan seluruh kolom input, dropdown, textarea, dan teks tampak jelas,
   berkontras tinggi, proporsional, dan sangat user-friendly.
   ========================================================================== */
main input[type="text"]:not(#barcodeInput),
main input[type="number"],
main input[type="password"],
main input[type="date"],
main input[type="email"],
main input[type="search"],
main select:not(#cameraSelect):not(#operatorCameraSelect),
main textarea,
#modalAddUser input,
#modalAddUser select,
#modalEditUser input,
#modalEditUser select,
#modalUploadRestore input,
#modalOperatorScanner select,
.admin-form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.625rem 0.875rem;
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1.5px solid #94a3b8 !important;
    border-radius: 0.75rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    outline: none !important;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

main input[type="file"],
#modalUploadRestore input[type="file"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem !important;
    background-color: #f8fafc !important;
    color: #1e293b !important;
    border: 1.5px dashed #94a3b8 !important;
    border-radius: 0.75rem !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}
main input[type="file"]:hover,
#modalUploadRestore input[type="file"]:hover {
    border-color: #0284c7 !important;
    background-color: #f0f9ff !important;
}

main input[type="text"]:not(#barcodeInput):focus,
main input[type="number"]:focus,
main input[type="password"]:focus,
main input[type="date"]:focus,
main input[type="email"]:focus,
main input[type="search"]:focus,
main select:not(#cameraSelect):not(#operatorCameraSelect):focus,
main textarea:focus,
#modalAddUser input:focus,
#modalAddUser select:focus,
#modalEditUser input:focus,
#modalEditUser select:focus,
#modalUploadRestore input:focus,
#modalOperatorScanner select:focus,
.admin-form-input:focus {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-color: #0284c7 !important;
    box-shadow: 0 0 0 3.5px rgba(2, 132, 199, 0.25) !important;
}

main input::placeholder,
main textarea::placeholder,
#modalAddUser input::placeholder,
#modalEditUser input::placeholder {
    color: #64748b !important;
    font-weight: 500 !important;
    opacity: 1 !important;
}

main select:not(#cameraSelect):not(#operatorCameraSelect) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23334155' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.75rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.25em 1.25em !important;
    padding-right: 2.25rem !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    cursor: pointer !important;
}

/* Penajaman Kontras Teks Muted (Membuat teks abu-abu yang pudar menjadi tegas dan mudah dibaca) */
main .text-slate-400 {
    color: #475569 !important; /* Ditingkatkan dari #94a3b8 ke #475569 agar tajam */
    font-weight: 600 !important;
}

main .text-slate-500 {
    color: #334155 !important; /* Ditingkatkan dari #64748b ke #334155 */
}

main table thead th {
    color: #0f172a !important; /* Judul kolom tabel hitam tegas & berwibawa */
    font-weight: 800 !important;
    letter-spacing: 0.05em !important;
}

/* Navigasi Aktif Bar Menu */
.nav-link-item {
    transition: all 0.15s ease-in-out;
}
.nav-link-item:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}
.nav-link-item.active {
    background-color: rgba(255, 255, 255, 0.28) !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.45) !important;
}

/* ==========================================================================
   BUTTON & UI UTILITIES (High Contrast, Missing Tailwind Color Definitions)
   Memastikan seluruh tombol tindakan, tombol C6, export/import, hapus,
   dan kontrol navigasi tampil jelas, tebal, berkontras tinggi dan rapi.
   ========================================================================== */

/* 1. Indigo Button & Badge Utilities */
.bg-indigo-50 { background-color: #eef2ff !important; }
.bg-indigo-100 { background-color: #e0e7ff !important; }
.bg-indigo-600 { background-color: #4f46e5 !important; }
.bg-indigo-700 { background-color: #4338ca !important; }
.hover\:bg-indigo-100:hover { background-color: #e0e7ff !important; }
.hover\:bg-indigo-700:hover { background-color: #4338ca !important; }
.hover\:bg-indigo-800:hover { background-color: #3730a3 !important; }
.active\:bg-indigo-200:active { background-color: #c7d2fe !important; }
.text-indigo-600 { color: #4f46e5 !important; }
.text-indigo-700 { color: #4338ca !important; }
.border-indigo-200 { border-color: #c7d2fe !important; }
.border-indigo-300 { border-color: #a5b4fc !important; }
.focus\:border-indigo-600:focus { border-color: #4f46e5 !important; }

/* 2. Rose / Red Button & Badge Utilities */
.bg-rose-50 { background-color: #fff1f2 !important; }
.bg-rose-100 { background-color: #ffe4e6 !important; }
.hover\:bg-rose-100:hover { background-color: #ffe4e6 !important; }
.active\:bg-rose-200:active { background-color: #fecdd3 !important; }
.text-rose-600 { color: #e11d48 !important; }
.text-rose-700 { color: #be123c !important; }
.border-rose-200 { border-color: #fecdd3 !important; }
.border-rose-300 { border-color: #fda4af !important; }
.hover\:bg-red-100:hover { background-color: #fee2e2 !important; }
.active\:bg-red-200:active { background-color: #fecaca !important; }

/* 3. Amber / Yellow Utilities */
.bg-amber-600 { background-color: #d97706 !important; }
.bg-amber-700 { background-color: #b45309 !important; }
.hover\:bg-amber-100:hover { background-color: #fef3c7 !important; }
.hover\:bg-amber-700:hover { background-color: #b45309 !important; }
.hover\:bg-amber-800:hover { background-color: #92400e !important; }
.active\:bg-amber-700:active { background-color: #b45309 !important; }
.active\:bg-amber-800:active { background-color: #92400e !important; }
.text-amber-300 { color: #fcd34d !important; }
.border-amber-300 { border-color: #fcd34d !important; }

/* 4. Sky & Emerald Hover / Active States */
.hover\:bg-sky-100:hover { background-color: #e0f2fe !important; }
.active\:bg-sky-200:active { background-color: #bae6fd !important; }
.hover\:bg-emerald-100:hover { background-color: #d1fae5 !important; }
.active\:bg-emerald-200:active { background-color: #a7f3d0 !important; }

/* 5. Slate Hover / Active Utilities */
.hover\:bg-slate-700:hover { background-color: #334155 !important; }
.hover\:bg-slate-800:hover { background-color: #1e293b !important; }
.hover\:bg-slate-900:hover { background-color: #0f172a !important; }
.active\:bg-slate-600:active { background-color: #475569 !important; }

/* 6. Spacing, Shadow, and State Helpers */
.cursor-pointer { cursor: pointer !important; }
.space-x-1 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.25rem !important; }
.space-x-1\.5 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.375rem !important; }
.space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.5rem !important; }
.shadow-xs { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important; }
.disabled\:bg-slate-300:disabled { background-color: #cbd5e1 !important; }
.disabled\:cursor-not-allowed:disabled { cursor: not-allowed !important; }



