/* ============================================================
   Tema "Bersih Terang" — dasar bersama semua halaman public-v2
   Token warna, reset, tipografi, tombol, topbar, footer, modal.
   ============================================================ */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  /* #64748b hanya 4,37:1 di atas --accent-soft (kartu Terlaris/terpilih). */
  --muted: #5b6b82;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-line: #bfdbfe;

  --ok: #16a34a;
  --ok-ink: #166534;
  --ok-soft: #f0fdf4;
  --ok-line: #bbf7d0;
  --warn: #d97706;
  --warn-ink: #92400e;
  --warn-soft: #fffbeb;
  --warn-line: #fde68a;
  --error: #dc2626;
  --error-ink: #991b1b;
  --error-soft: #fef2f2;
  --error-line: #fecaca;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --page-width: 1080px;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);
  /* Teks di atas latar aksen/status dan di atas latar --ink (tombol gelap). */
  --on-accent: #ffffff;
  --on-ink: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --veil: rgba(248, 250, 252, 0.82);
  color-scheme: light;
}

/* Tema gelap pilihan pengunjung (public/theme-toggle.js). Hanya token + permukaan yang ditulis langsung. */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #172033;
  --ink: #e5e7eb;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #243044;
  --line-strong: #334155;

  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --accent-line: rgba(96, 165, 250, 0.4);

  --ok: #4ade80;
  --ok-ink: #86efac;
  --ok-soft: rgba(34, 197, 94, 0.12);
  --ok-line: rgba(74, 222, 128, 0.35);
  --warn: #fbbf24;
  --warn-ink: #fcd34d;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-line: rgba(251, 191, 36, 0.35);
  --error: #f87171;
  --error-ink: #fca5a5;
  --error-soft: rgba(248, 113, 113, 0.12);
  --error-line: rgba(248, 113, 113, 0.35);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.35);
  --on-accent: #0b1120;
  --on-ink: #0b1120;
  --topbar-bg: rgba(11, 17, 32, 0.92);
  --veil: rgba(11, 17, 32, 0.82);
  color-scheme: dark;
}

:root[data-theme="dark"] .action-ghost:hover {
  background: var(--accent-soft);
}

/* Tombol ganti tema di header (dibuat public/theme-toggle.js). */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--surface-2);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.page-container {
  width: min(var(--page-width), calc(100% - 32px));
  margin: 0 auto;
}

/* ---- Topbar ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 54px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: block;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-nav a {
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
}

.topbar-nav a:hover {
  color: var(--accent);
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 0.9rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.topbar-link:hover {
  background: var(--accent-hover);
}

.topbar-link--ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.topbar-link--ghost:hover {
  background: var(--surface-2);
}

/* ---- Tombol umum ------------------------------------------------------- */

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.action-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.action-primary:hover {
  background: var(--accent-hover);
}

.action-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.action-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action-ghost {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}

.action-ghost:hover {
  background: #dbeafe;
}

/* ---- Footer ------------------------------------------------------------ */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1.25rem;
  padding: 1rem 0;
}

.site-footer-brand {
  display: grid;
  gap: 0.15rem;
}

.site-footer-brand strong {
  font-size: 0.88rem;
}

.site-footer-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
}

.site-footer-links a {
  color: var(--ink-2);
  font-size: 0.8rem;
  text-decoration: none;
}

.site-footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---- Modal ------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  /* Kartu yang lebih tinggi dari layar HP harus bisa digulir, jangan terpotong. */
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: modal-overlay-enter 160ms ease-out;
}

.modal-card {
  /* margin auto: di tengah saat muat, menempel atas (bukan terpotong) saat lebih tinggi. */
  margin: auto 0;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-card-enter 200ms cubic-bezier(0.2, 0.82, 0.2, 1) both;
}

.modal-header,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.modal-header h3,
.modal-head h3 {
  font-size: 0.95rem;
}

.modal-close,
.modal-close-btn {
  min-height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.modal-close:hover,
.modal-close-btn:hover {
  background: var(--surface-2);
}

.modal-body {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem 0.9rem 0.95rem;
}

.credential-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.credential-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.credential-value {
  margin: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.86rem;
  font-weight: 700;
  word-break: break-all;
}

.copy-btn,
.copy-inline-btn {
  min-height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn:hover,
.copy-inline-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes modal-overlay-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-card-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-card {
    animation: none !important;
  }
}

@media (max-width: 720px) {
  .topbar-nav {
    display: none;
  }

  .topbar-inner {
    min-height: 50px;
    gap: 0.6rem;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .credential-row {
    grid-template-columns: 1fr;
  }
}

/* Tombol member di header (public/index.js): tamu "Daftar / Masuk", member login nama + saldo. */
.topbar-member {
  gap: 0.4rem;
  max-width: 48vw;
  white-space: nowrap;
}

.topbar-member-name {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-member-balance {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.topbar-actions .topbar-link,
.topbar-member {
  white-space: nowrap;
}

/* Layar sempit: nama & saldo dua baris kecil supaya "Sewa Sekarang" tetap utuh di sebelahnya. */
/* Grup tombol tidak menyusut; merek toko yang mengalah (melipat) bila sempit. */
.topbar-actions {
  flex: 0 0 auto;
}

.topbar .brand {
  min-width: 0;
}

@media (max-width: 560px) {
  .topbar-actions {
    gap: 0.35rem;
  }

  .topbar .brand {
    font-size: 0.74rem;
  }

  .topbar-actions .topbar-link {
    padding: 0.32rem 0.62rem;
    font-size: 0.76rem;
  }

  .topbar-member {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    line-height: 1.15;
  }

  .topbar-member-name {
    max-width: 5.5rem;
    font-size: 0.72rem;
  }

  .topbar-member-balance {
    font-size: 0.68rem;
  }
}
