/* =====================================================================
   Pemilihan Ketua Paguyuban The Cemandi — Design System
   Konsep: kartu suara & tinta ungu pemilu Indonesia sebagai motif utama.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Warna ---- */
  --paper: #F6F3EC;
  --paper-raised: #FFFFFF;
  --ink-navy: #1C2B42;
  --ink-navy-soft: #3B4A63;
  --line: #E4DFD2;

  --gold: #D9A441;
  --gold-deep: #B9832A;
  --gold-tint: #FBF0D9;

  --violet: #4E2A83;
  --violet-deep: #38205F;
  --violet-tint: #EEE6F7;

  --green: #3F7150;
  --green-tint: #E4EFE6;
  --red: #B23A3A;
  --red-tint: #F6E4E2;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-card: 0 2px 8px rgba(28,43,66,0.06), 0 1px 2px rgba(28,43,66,0.08);
  --shadow-raised: 0 12px 32px rgba(28,43,66,0.14), 0 2px 8px rgba(28,43,66,0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink-navy);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Tekstur kertas halus di background */
body.paper-texture {
  background-image:
    radial-gradient(circle at 15% 20%, rgba(217,164,65,0.06), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(78,42,131,0.05), transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink-navy); }
p { margin: 0; }
a { color: inherit; }

::selection { background: var(--violet); color: #fff; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---- Layout util ---- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 560px; margin: 0 auto; padding: 0 20px; }

/* ---- Top bar / eyebrow ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--ink-navy);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-family: var(--font-display); font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}
.brand-text { line-height: 1.2; }
.brand-text .eyebrow { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-navy-soft); font-weight: 600; }
.brand-text .title { font-family: var(--font-display); font-weight: 600; font-size: 16px; }

/* ---- Cards ---- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 28px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 700; font-size: 15px;
  padding: 14px 24px; border-radius: 999px; border: none; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  text-decoration: none;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink-navy); color: #fff; box-shadow: 0 4px 14px rgba(28,43,66,0.25); }
.btn-primary:hover:not(:disabled) { background: #16213333; box-shadow: 0 6px 18px rgba(28,43,66,0.3); background: #14203a; }
.btn-gold { background: var(--gold); color: var(--ink-navy); box-shadow: 0 4px 14px rgba(217,164,65,0.4); }
.btn-gold:hover:not(:disabled) { background: var(--gold-deep); }
.btn-violet { background: var(--violet); color: #fff; box-shadow: 0 4px 14px rgba(78,42,131,0.3); }
.btn-violet:hover:not(:disabled) { background: var(--violet-deep); }
.btn-outline { background: transparent; color: var(--ink-navy); border: 1.5px solid var(--line); }
.btn-outline:hover:not(:disabled) { border-color: var(--ink-navy); }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #efd0cd; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 16px; font-size: 13px; min-height: 36px; }

/* ---- Form ---- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-navy-soft); margin-bottom: 6px; letter-spacing: 0.01em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--paper);
  font-family: var(--font-body); font-size: 16px; color: var(--ink-navy);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--violet); background: #fff;
}
.field .hint { font-size: 12px; color: var(--ink-navy-soft); margin-top: 5px; }
.field-pin input { font-family: var(--font-mono); letter-spacing: 0.4em; font-size: 22px; text-align: center; }

/* ---- Alert / toast ---- */
.alert { border-radius: var(--radius-sm); padding: 13px 16px; font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: var(--red-tint); color: var(--red); }
.alert-success { background: var(--green-tint); color: var(--green); }
.alert-info { background: var(--violet-tint); color: var(--violet); }

/* ---- Badge nomor urut kandidat (dari kartu suara asli) ---- */
.number-badge {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--paper); border: 2.5px solid var(--ink-navy);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 22px; color: var(--ink-navy);
  flex-shrink: 0;
}

/* ---- Kartu kandidat (ballot card) ---- */
.candidate-card {
  background: var(--paper-raised);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  text-align: left;
  width: 100%;
  font-family: inherit;
  position: relative;
}
.candidate-card:hover { border-color: var(--gold); box-shadow: var(--shadow-raised); }
.candidate-card.selected { border-color: var(--violet); background: var(--violet-tint); box-shadow: var(--shadow-raised); }
.candidate-card.selected .number-badge { border-color: var(--violet); background: var(--violet); color: #fff; }
.candidate-photo {
  width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--ink-navy), #2a3d5c);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.5); font-size: 13px; margin-bottom: 16px; overflow: hidden;
}
.candidate-photo img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Stempel tinta (signature element) ---- */
.ink-stamp {
  width: 132px; height: 132px; margin: 0 auto;
  position: relative;
}
.ink-stamp svg { width: 100%; height: 100%; }
.ink-stamp-appear { animation: stampIn 0.55s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stampIn {
  0% { transform: scale(2.2) rotate(-8deg); opacity: 0; }
  60% { transform: scale(0.92) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}

/* ---- Progress bar hasil (papan pengumuman) ---- */
.result-row { margin-bottom: 22px; }
.result-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 12px; }
.result-bar-track { height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.result-bar-fill { height: 100%; background: linear-gradient(90deg, var(--violet-deep), var(--violet)); border-radius: 999px; transition: width 0.6s cubic-bezier(.3,.7,.3,1); }
.result-bar-fill.leading { background: linear-gradient(90deg, var(--gold-deep), var(--gold)); }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ink-navy); color: #fff; font-size: 12px; font-weight: 700;
  padding: 7px 14px; border-radius: 999px; letter-spacing: 0.05em;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; animation: pulseDot 1.6s ease-in-out infinite; }
@keyframes pulseDot { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,0.5); } 50% { opacity: 0.6; box-shadow: 0 0 0 5px rgba(74,222,128,0); } }

/* ---- Stat card (admin) ---- */
.stat-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; }
.stat-card .value { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--ink-navy); }
.stat-card .label { font-size: 13px; color: var(--ink-navy-soft); font-weight: 600; margin-top: 4px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper-raised); }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
th { text-align: left; padding: 12px 16px; background: var(--paper); font-weight: 700; color: var(--ink-navy-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill-voted { background: var(--green-tint); color: var(--green); }
.pill-not-voted { background: var(--line); color: var(--ink-navy-soft); }
.pill-inactive { background: var(--red-tint); color: var(--red); }
.pill-warn { background: var(--gold-tint); color: var(--gold-deep); }

/* ---- Admin shell ---- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 240px; background: var(--ink-navy); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.admin-sidebar .brand-text .title, .admin-sidebar .brand-text .eyebrow { color: #fff; }
.admin-sidebar .brand-mark { background: var(--gold); color: var(--ink-navy); }
.admin-nav { margin-top: 28px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75); text-decoration: none; font-weight: 600; font-size: 14px;
}
.admin-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-nav a.active { background: var(--gold); color: var(--ink-navy); }
.admin-main { flex: 1; padding: 28px 32px; max-width: 100%; overflow-x: hidden; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }

.mobile-menu-btn { display: none; }

@media (max-width: 860px) {
  .admin-sidebar { position: fixed; left: -260px; z-index: 50; transition: left 0.2s ease; box-shadow: var(--shadow-raised); }
  .admin-sidebar.open { left: 0; }
  .admin-main { padding: 20px 16px; }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40; }
  .sidebar-overlay.open { display: block; }
}

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(28,43,66,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 28px; max-width: 440px; width: 100%; box-shadow: var(--shadow-raised); max-height: 90vh; overflow-y: auto; }

/* ---- Misc ---- */
.muted { color: var(--ink-navy-soft); }
.center { text-align: center; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner-dark { border: 2.5px solid rgba(28,43,66,0.2); border-top-color: var(--ink-navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, #efe9d8 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.grid-candidates { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }

.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: stretch; }
.dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) {
  .hero-grid, .dash-grid, .settings-grid { grid-template-columns: 1fr; }
}

footer.site-footer { text-align: center; padding: 32px 20px; color: var(--ink-navy-soft); font-size: 13px; }
