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

:root {
    --blue:        #2563eb;
    --blue-dark:   #1d4ed8;
    --blue-light:  #eff6ff;
    --green:       #16a34a;
    --green-light: #dcfce7;
    --red:         #dc2626;
    --red-light:   #fee2e2;
    --yellow:      #d97706;
    --yellow-light:#fef3c7;
    --gray-50:     #f9fafb;
    --gray-100:    #f3f4f6;
    --gray-200:    #e5e7eb;
    --gray-300:    #d1d5db;
    --gray-400:    #9ca3af;
    --gray-500:    #6b7280;
    --gray-600:    #4b5563;
    --gray-700:    #374151;
    --gray-800:    #1f2937;
    --gray-900:    #111827;
    --radius:      .75rem;
    --radius-sm:   .375rem;
    --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:   0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
    --transition:  .2s ease;
}

html { font-size: 16px; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; color: var(--gray-800); background: var(--gray-50); line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ===== NAVBAR ===== */
.navbar { background: #fff; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 100; }
.nav-container { max-width: 1200px; margin: 0 auto; padding: .875rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { display: flex; align-items: center; gap: .625rem; font-weight: 700; font-size: 1.125rem; color: var(--gray-900); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 1rem; }
.nav-name { font-size: .875rem; color: var(--gray-600); font-weight: 500; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem 1.125rem; border-radius: var(--radius-sm); font-size: .875rem; font-weight: 500; cursor: pointer; border: 1.5px solid transparent; transition: background var(--transition), border-color var(--transition), box-shadow var(--transition); text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-full { width: 100%; justify-content: center; padding: .75rem 1.5rem; font-size: .9375rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }

/* ===== ALERTS ===== */
.alert { padding: .875rem 1rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-error   { background: var(--red-light);    color: #991b1b; border-color: #fca5a5; }
.alert-success { background: var(--green-light);  color: #166534; border-color: #86efac; }
.alert-warning { background: var(--yellow-light); color: #92400e; border-color: #fcd34d; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: .375rem; flex: 1; min-width: 0; }
.form-group label { font-size: .8125rem; font-weight: 600; color: var(--gray-700); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-control { padding: .625rem .875rem; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: .9375rem; font-family: inherit; color: var(--gray-800); background: #fff; transition: border-color var(--transition), box-shadow var(--transition); width: 100%; }
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-check { display: flex; align-items: flex-start; gap: .625rem; font-size: .875rem; color: var(--gray-600); }
.form-check input { margin-top: .2rem; accent-color: var(--blue); flex-shrink: 0; }
.input-password { position: relative; }
.input-password .form-control { padding-right: 2.75rem; }
.toggle-pw { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--gray-400); display: flex; padding: 0; }
.toggle-pw:hover { color: var(--gray-700); }
.toggle-pw svg { width: 18px; height: 18px; }

/* ===== AUTH LAYOUT ===== */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; background: var(--gray-50); }
.auth-split { display: flex; min-height: 100vh; }
.auth-panel-left { flex: 0 0 420px; background: linear-gradient(145deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%); color: #fff; display: flex; flex-direction: column; padding: 2.5rem; position: relative; overflow: hidden; }
.auth-panel-left::before { content: ''; position: absolute; top: -60px; right: -60px; width: 300px; height: 300px; border-radius: 50%; background: rgba(255,255,255,.06); pointer-events: none; }
.auth-panel-left::after  { content: ''; position: absolute; bottom: -80px; left: -40px; width: 250px; height: 250px; border-radius: 50%; background: rgba(255,255,255,.05); pointer-events: none; }
.auth-brand { display: flex; align-items: center; gap: .75rem; font-weight: 700; font-size: 1.25rem; margin-bottom: auto; }
.auth-panel-content { padding: 2.5rem 0; }
.auth-panel-content h1 { font-size: 2.25rem; font-weight: 700; line-height: 1.2; margin-bottom: 1rem; }
.auth-panel-content p { font-size: 1rem; opacity: .85; margin-bottom: 2rem; }
.auth-features { list-style: none; display: flex; flex-direction: column; gap: .75rem; font-size: .9375rem; opacity: .9; }
.auth-features li { display: flex; align-items: center; gap: .625rem; }
.auth-features svg { width: 18px; height: 18px; color: #86efac; flex-shrink: 0; }

.auth-panel-right { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2.5rem; width: 100%; max-width: 440px; border: 1px solid var(--gray-200); }
.auth-card-wide { max-width: 720px; }
.auth-card-header { margin-bottom: 1.75rem; }
.auth-card-header h2 { font-size: 1.625rem; font-weight: 700; color: var(--gray-900); margin-bottom: .375rem; }
.auth-card-header p { color: var(--gray-500); font-size: .9375rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.125rem; margin-bottom: 1.25rem; }
.auth-switch { text-align: center; font-size: .875rem; color: var(--gray-500); }
.auth-notice { text-align: center; font-size: .8125rem; color: var(--gray-400); margin-top: 1rem; line-height: 1.5; }

.auth-body-center { align-items: center; justify-content: center; }

/* ===== OTP ===== */
.otp-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2.75rem 2.5rem; max-width: 440px; width: 100%; text-align: center; border: 1px solid var(--gray-200); }
.otp-icon { width: 64px; height: 64px; background: var(--blue-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.25rem; }
.otp-icon svg { width: 30px; height: 30px; stroke: var(--blue); }
.otp-card h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem; }
.otp-card > p { color: var(--gray-500); font-size: .9375rem; margin-bottom: 1.5rem; }
.otp-form { display: flex; flex-direction: column; gap: 1.25rem; }
.otp-inputs { display: flex; gap: .625rem; justify-content: center; }
.otp-digit { width: 52px; height: 60px; border: 2px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 1.5rem; font-weight: 700; text-align: center; color: var(--gray-900); transition: border-color var(--transition); }
.otp-digit:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.otp-timer { font-size: .875rem; color: var(--gray-400); }

/* ===== MAIN CONTENT ===== */
.main-content { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.container { max-width: 960px; margin: 0 auto; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }

/* ===== BALLOT ===== */
.ballot-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 2rem; gap: 1rem; flex-wrap: wrap; }
.ballot-title { font-size: 1.625rem; font-weight: 700; }
.ballot-meta { font-size: .875rem; color: var(--gray-500); margin-top: .25rem; }
.ballot-badge { background: #ef4444; color: #fff; font-size: .75rem; font-weight: 700; letter-spacing: .08em; padding: .25rem .625rem; border-radius: 999px; animation: pulse-badge 2s infinite; }
@keyframes pulse-badge { 0%,100%{opacity:1}50%{opacity:.7} }

.ballot-section { margin-bottom: 2.5rem; }
.ballot-section-title { font-size: 1rem; font-weight: 700; color: var(--gray-700); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; padding-bottom: .75rem; border-bottom: 2px solid var(--blue-light); }
.ballot-section-title svg { width: 18px; height: 18px; color: var(--blue); }

.candidates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.candidate-card { display: flex; flex-direction: column; align-items: center; background: #fff; border: 2px solid var(--gray-200); border-radius: var(--radius); padding: 1.5rem 1rem; cursor: pointer; transition: border-color .2s, box-shadow .2s, transform .15s; position: relative; text-align: center; }
.candidate-card:hover { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); transform: translateY(-2px); }
.candidate-radio { position: absolute; opacity: 0; width: 0; height: 0; }
.candidate-radio:checked ~ .candidate-check { opacity: 1; }
.candidate-card:has(.candidate-radio:checked) { border-color: var(--blue); background: var(--blue-light); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.candidate-photo { width: 80px; height: 80px; border-radius: 50%; overflow: hidden; margin-bottom: .875rem; background: var(--gray-100); border: 3px solid var(--gray-200); }
.candidate-photo img { width: 100%; height: 100%; object-fit: cover; }
.candidate-initials { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.75rem; font-weight: 700; color: var(--blue); background: var(--blue-light); }
.candidate-info h4 { font-size: .9375rem; font-weight: 700; }
.candidate-info p { font-size: .8125rem; color: var(--gray-400); margin-top: .25rem; }
.candidate-check { position: absolute; top: .75rem; right: .75rem; width: 22px; height: 22px; color: var(--blue); opacity: 0; transition: opacity .2s; }
.candidate-check svg { width: 22px; height: 22px; }

.ballot-actions { display: flex; justify-content: center; padding: 2rem 0; }

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); backdrop-filter: blur(3px); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 2rem; max-width: 400px; width: 90%; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: .75rem; }
.modal p { color: var(--gray-500); font-size: .9375rem; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ===== VOTE SUCCESS ===== */
.vote-success-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 3rem 2.5rem; max-width: 560px; margin: 3rem auto; text-align: center; box-shadow: var(--shadow-lg); }
.success-icon { width: 72px; height: 72px; background: var(--green-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem; }
.success-icon svg { width: 36px; height: 36px; stroke: var(--green); }
.vote-success-card h2 { font-size: 1.625rem; font-weight: 700; margin-bottom: .75rem; }
.vote-success-card p { color: var(--gray-500); margin-bottom: 1.5rem; }
.receipt-box { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1.5rem; text-align: left; }
.receipt-label { font-size: .75rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.receipt-hash { font-size: .75rem; word-break: break-all; color: var(--gray-700); font-family: monospace; }

/* ===== RESULTS ===== */
.results-meta { margin-bottom: 2rem; }
.results-meta h2 { font-size: 1.375rem; font-weight: 700; }
.results-meta p { color: var(--gray-500); margin-top: .25rem; }
.results-section { margin-bottom: 2.5rem; }
.results-position { font-size: 1rem; font-weight: 700; color: var(--gray-700); padding-bottom: .75rem; border-bottom: 2px solid var(--blue-light); margin-bottom: 1rem; }
.results-list { display: flex; flex-direction: column; gap: .875rem; }
.result-row { display: flex; align-items: center; gap: 1rem; background: #fff; border: 1.5px solid var(--gray-200); border-radius: var(--radius); padding: 1rem 1.25rem; position: relative; }
.result-row.result-winner { border-color: #fbbf24; background: #fffbeb; }
.winner-badge { color: #d97706; }
.winner-badge svg { width: 22px; height: 22px; }
.result-photo { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--gray-100); border: 2px solid var(--gray-200); flex-shrink: 0; }
.result-photo img { width: 100%; height: 100%; object-fit: cover; }
.result-initials { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.125rem; color: var(--blue); background: var(--blue-light); }
.result-details { flex: 1; min-width: 0; }
.result-name-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.result-name-row strong { font-size: .9375rem; }
.result-name-row span { font-size: .8125rem; color: var(--gray-400); }
.result-bar-wrap { height: 8px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.result-bar { height: 100%; background: var(--blue); border-radius: 99px; transition: width .6s ease; }
.result-winner .result-bar { background: #d97706; }
.result-stats { display: flex; flex-direction: column; align-items: flex-end; gap: .125rem; flex-shrink: 0; }
.result-count { font-size: .9375rem; font-weight: 700; }
.result-pct { font-size: .8125rem; color: var(--gray-400); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 5rem 2rem; }
.empty-state svg { width: 52px; height: 52px; stroke: var(--gray-300); margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.25rem; font-weight: 700; color: var(--gray-700); margin-bottom: .5rem; }
.empty-state p { color: var(--gray-400); font-size: .9375rem; }
.empty-state-voted svg { stroke: var(--green); }

/* ===== BADGES ===== */
.status-badge,.badge { display: inline-flex; align-items: center; padding: .25rem .75rem; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; }
.status-active,.badge-active { background: var(--green-light); color: #166534; }
.status-completed,.badge-completed { background: var(--gray-100); color: var(--gray-600); }
.badge-pending { background: var(--yellow-light); color: #92400e; }

/* ===== FOOTER ===== */
.footer { border-top: 1px solid var(--gray-200); background: #fff; margin-top: 4rem; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.footer-inner p { font-size: .8125rem; color: var(--gray-400); }
.footer-note { font-size: .75rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .auth-panel-left { flex: 0 0 300px; }
    .auth-panel-left h1 { font-size: 1.75rem; }
}
@media (max-width: 680px) {
    .auth-split { flex-direction: column; }
    .auth-panel-left { flex: none; padding: 2rem; }
    .auth-panel-content { padding: 1.5rem 0 .5rem; }
    .auth-panel-left h1 { font-size: 1.5rem; }
    .auth-panel-right { padding: 1.5rem; }
    .auth-features { display: none; }
    .candidates-grid { grid-template-columns: 1fr 1fr; }
}
