/* =========================================
   SISTEM PEMILIHAN KETUA RW - VOTING STYLES
   ========================================= */

:root {
    --primary: #e85d04;
    --primary-dark: #d9480f;
    --secondary: #2f3e46;
    --success: #2b9348;
    --danger: #bc4749;
    --warning: #f48c06;
    --dark: #102a43;
    --light: #f8f5f2;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --shadow: 0 10px 25px -15px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 24px 42px -24px rgb(0 0 0 / 0.45);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background:
        radial-gradient(circle at 10% 10%, #fef3c7 0%, transparent 40%),
        radial-gradient(circle at 90% 20%, #bfdbfe 0%, transparent 45%),
        linear-gradient(145deg, #102a43 0%, #243b53 40%, #334e68 100%);
    min-height: 100vh;
    color: var(--light);
    overflow-x: hidden;
}

/* =========================================
   VOTING PAGE
   ========================================= */

.bg-orb {
    position: fixed;
    border-radius: 999px;
    filter: blur(8px);
    z-index: 0;
    pointer-events: none;
}

.bg-orb-a {
    width: 280px;
    height: 280px;
    top: -60px;
    right: -90px;
    background: rgba(255, 183, 3, 0.2);
}

.bg-orb-b {
    width: 320px;
    height: 320px;
    bottom: -120px;
    left: -120px;
    background: rgba(56, 189, 248, 0.18);
}

.voting-container {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding: 46px 20px 52px;
}

.voting-header {
    text-align: center;
    margin-bottom: 38px;
    color: #fff;
}

.voting-header .eyebrow {
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 700;
    color: #ffd166;
    margin-bottom: 10px;
}

.voting-header h1 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.6rem, 7vw, 5.4rem);
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    text-shadow: 0 10px 20px rgba(0, 0, 0, 0.38);
}

.voting-header .subtitle {
    font-size: clamp(1rem, 2vw, 1.12rem);
    opacity: 0.92;
    max-width: 760px;
    margin: 0 auto;
}

.voting-status-badge {
    display: inline-block;
    padding: 9px 20px;
    border-radius: 50px;
    font-weight: 700;
    margin-top: 16px;
    letter-spacing: 0.03em;
    animation: pulse 2s infinite;
}

.voting-status-badge.open {
    background: var(--success);
    color: white;
}

.voting-status-badge.closed {
    background: var(--danger);
    color: white;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* =========================================
   VOTER GATE FORM
   ========================================= */

.card {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(6px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.voter-gate-card {
    max-width: 720px;
    margin: 0 auto 34px;
}

.card-body {
    padding: 28px;
}

.voter-gate-card h3 {
    color: var(--dark);
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.gate-subtitle {
    color: #486581;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 20px;
}

.gate-input-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #d9e2ec;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(232, 93, 4, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(216, 76, 26, 0.28);
}

.btn-block-main {
    width: 100%;
}

.btn-secondary {
    background: linear-gradient(135deg, #0ea5e9, #0369a1);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(14, 165, 233, 0.32);
}

.btn-danger-soft {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: white;
}

.btn-danger-soft:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.3);
}

.scan-divider {
    margin: 20px 0 16px;
    text-align: center;
    color: #64748b;
    font-size: 0.92rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.qr-scan-panel {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 14px;
}

.qr-scan-subtitle {
    color: #334155;
    font-size: 0.92rem;
    margin-bottom: 12px;
}

.qr-scan-feedback {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 0.92rem;
    font-weight: 600;
}

.qr-reader {
    width: 100%;
    min-height: 240px;
    margin-bottom: 12px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #bae6fd;
    background: #e0f2fe;
}

.qr-scan-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* =========================================
   CANDIDATE CARDS
   ========================================= */

.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 22px;
    justify-content: center;
}

.candidate-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.candidate-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 30px 35px -22px rgba(0, 0, 0, 0.45);
}

.candidate-photo-container {
    position: relative;
    width: 100%;
    height: 330px;
    overflow: hidden;
    background: linear-gradient(155deg, #fff7ed 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.candidate-photo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.candidate-photo-container.photo-cover .candidate-photo {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: center top;
}

.candidate-card:hover .candidate-photo {
    transform: scale(1.05);
}

/* Paku Animation */
.paku-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
}

.paku {
    width: 60px;
    height: 120px;
    position: relative;
}

.paku-head {
    width: 60px;
    height: 15px;
    background: linear-gradient(135deg, #555 0%, #333 100%);
    border-radius: 3px 3px 0 0;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

.paku-body {
    width: 10px;
    height: 105px;
    background: linear-gradient(90deg, #888 0%, #666 50%, #888 100%);
    margin: 0 auto;
    clip-path: polygon(0 0, 100% 0, 70% 100%, 30% 100%);
}

.paku-tip {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 20px solid #666;
    margin: 0 auto;
    transform: translateY(-5px);
}

.candidate-card.coblos .paku-container {
    animation: coblosAnimation 0.6s ease forwards;
}

@keyframes coblosAnimation {
    0% {
        opacity: 1;
        transform: translate(-50%, -200%);
    }
    50% {
        transform: translate(-50%, -50%);
    }
    60% {
        transform: translate(-50%, -45%);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.coblos-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    z-index: 5;
    opacity: 0;
}

.candidate-card.coblos .coblos-hole {
    animation: holeAnimation 0.6s ease forwards;
    animation-delay: 0.3s;
}

@keyframes holeAnimation {
    0% {
        width: 0;
        height: 0;
        opacity: 0;
    }
    100% {
        width: 40px;
        height: 40px;
        opacity: 1;
    }
}

.candidate-info {
    padding: 22px;
    text-align: center;
}

.candidate-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.candidate-vision {
    font-size: 0.95rem;
    color: #52606d;
    margin-bottom: 20px;
    line-height: 1.5;
    min-height: 58px;
}

.btn-coblos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.btn-coblos:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 12px 22px rgba(216, 76, 26, 0.35);
}

.btn-coblos:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.candidate-card.voted .btn-coblos {
    display: none;
}

.voted-badge {
    display: none;
    padding: 14px;
    background: var(--success);
    color: white;
    border-radius: 10px;
    font-weight: 600;
    text-align: center;
}

.candidate-card.voted .voted-badge {
    display: block;
}

/* =========================================
   CLOSED / LOADING STATES
   ========================================= */

.closed-message {
    background: white;
    padding: 36px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
}

.closed-message h2 {
    color: var(--dark);
    margin-bottom: 15px;
}

.closed-message p {
    color: var(--gray-500);
}

.closed-subtext {
    margin-top: 15px;
    font-size: 0.95rem;
}

.closed-footnote {
    margin-top: 20px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.candidates-loading {
    text-align: center;
    padding: 40px;
    color: #e0f2fe;
}

.candidates-loading .spinner {
    margin: 0 auto 18px;
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: #fef3c7;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.realtime-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(8, 47, 73, 0.9);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(2, 6, 23, 0.35);
    z-index: 100;
}

.realtime-badge .dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

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

@media (max-width: 768px) {
    .voting-container {
        padding-top: 28px;
    }

    .voting-header h1 {
        font-size: 3.1rem;
    }

    .candidates-grid {
        grid-template-columns: 1fr;
    }

    .voter-gate-card {
        margin-bottom: 24px;
    }

    .card-body {
        padding: 20px;
    }

    .qr-reader {
        min-height: 210px;
    }

    .realtime-badge {
        right: 14px;
        bottom: 14px;
    }
}
