/* Shared design tokens + base components for index.html and admin.html.
   Page-specific layout (calendar timeline, admin table, modal/form fields)
   stays in each page's own inline <style> block — this file only holds what
   both pages need identically, to avoid duplicating the same rules twice. */

:root {
  --ink: #111827;
  --body-text: #374151;
  --muted: #6b7280;
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;

  --primary: #0f6e56;
  --primary-hover: #0b5a46;
  --primary-soft: #e3f1ec;

  --accent: #c4d600;
  --accent-hover: #a8b800;
  --accent-soft: #f5f9dc;

  /* "Tersedia" (available) timeline slot background — a visibly green wash,
     distinct from --accent-soft's much paler tint used for badges/chips. */
  --available-bg: #c9e4a5;
  --available-bg-hover: #bcdb90;

  --neutral-zoom: #94a3b8;

  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

/* Components in this file (and the pages that use it) set their own
   `display` value (flex/inline-flex/etc) and toggle visibility via the
   `hidden` attribute/property in JS. Without this rule, an author-defined
   `display` always wins over the browser's built-in `[hidden] {
   display:none }` UA-stylesheet rule (same specificity, but UA-origin
   styles lose to author styles) — so `el.hidden = true` silently does
   nothing and the element stays visible forever. This was the root cause
   of the "loading spinner never stops" bug. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--body-text);
  background: var(--bg);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.app-footer {
  text-align: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---------- Header / topbar (with subtle "K" brand mark) ---------- */
.topbar {
  position: relative;
  background: var(--primary);
  color: #fff;
}
.topbar-inner {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}
.topbar p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
}
.topbar a {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.82rem;
  text-decoration: none;
}
.topbar a:hover {
  color: #fff;
  text-decoration: underline;
}
/* Right-hand cluster of the topbar (user identity + nav links + primary
   CTA) — groups plain-text nav links into a pill so they read as a unit
   instead of loose words floating next to the CTA button. */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar-username {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}
.topbar-nav a {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.topbar-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  text-decoration: none;
}

/* User identity + logout, collapsed into a dropdown (avatar initials +
   caret) instead of a bare name floating in the topbar — the panel below
   carries the full name and the "Keluar" action. */
.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.user-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.2);
}
.user-menu-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}
.user-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-menu-caret {
  color: rgba(255, 255, 255, 0.8);
  transition: transform 0.15s ease;
}
.user-menu.open .user-menu-caret {
  transform: rotate(180deg);
}
.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 200px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.18);
  padding: 12px;
}
.user-menu-fullname {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
/* Selector needs 2 classes' worth of specificity (not just `.user-menu-logout`)
   to beat `.topbar a`'s color rule above — `.topbar a` matches this link too
   (it's a descendant of .topbar) and previously won on specificity, making
   the "Keluar" text render near-white on the panel's white background. */
.user-menu-panel .user-menu-logout {
  display: block;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  padding: 4px 0;
}
.user-menu-panel .user-menu-logout:hover {
  /* Restated here (not just on the base rule above) because `.topbar
     a:hover` — which also matches this link, being a descendant of .topbar
     — has higher specificity for `color` on :hover specifically, and would
     otherwise flip it to near-white on the panel's white background. */
  color: var(--danger);
  text-decoration: underline;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Small logo-mark badge (abstract, inspired by the Kemenkes logo's angular
   two-tone shape) placed next to the title — replaces the earlier giant
   background watermark. */
.brand-mark {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 700px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease,
    transform 0.05s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

/* For primary CTAs placed on top of the teal .topbar — a solid-teal button
   would be nearly invisible on a solid-teal header, so this inverts to a
   white pill with teal text instead. */
.btn-on-primary {
  background: #fff;
  color: var(--primary);
}
.btn-on-primary:hover:not(:disabled) {
  background: var(--primary-soft);
}
.btn-on-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

/* Lime accent CTA — dark text for contrast against the light accent color
   (a light bg like #C4D600 needs dark, not white, text to stay readable). */
.btn-accent {
  background: var(--accent);
  color: var(--ink);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-accent:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--body-text);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: #fff;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}
.btn-danger:focus-visible {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.btn-block {
  display: flex;
  width: 100%;
  margin-top: 16px;
}

.btn-icon {
  padding: 6px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.btn-icon:hover {
  background: var(--bg);
  color: var(--ink);
}
.btn-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- Filter chips ---------- */
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--body-text);
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.chip:has(input:focus-visible) {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Standalone lime-tinted chip for one-off actions (e.g. "Hari ini") — not
   part of the checkbox-driven .chip toggle group above. */
.chip-accent {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent-hover);
  background: var(--accent-soft);
  color: #4d5900;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}
.chip-accent:hover {
  background: var(--accent);
}
.chip-accent:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Date pill (prev/label/next date navigator) ---------- */
.date-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.date-pill-arrow {
  border: none;
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--body-text);
  font-size: 0.9rem;
  line-height: 1;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}
.date-pill-arrow:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.date-pill-arrow:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.date-pill-label {
  border: none;
  background: transparent;
  padding: 8px 6px;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
}
.date-pill-label:hover {
  color: var(--primary);
}
.date-pill-label:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
  border-radius: var(--radius-sm);
}

/* Keeps a native <input> usable (showPicker(), keyboard, screen readers)
   while visually replaced by a custom-styled control. Unlike display:none,
   this doesn't remove it from the accessibility tree or break focus/click. */
.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- Status/category pills (shape only — each page supplies its own
   color variants for .badge / .status-pill on top of this) ---------- */
.pill-base {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.6;
}
/* Status-pill color variants, shared by admin.html (raw booking status:
   terkonfirmasi/dibatalkan) and my-bookings.html (derived display status:
   akan_datang/selesai/dibatalkan) — previously each page defined its own
   copy of `.dibatalkan` (identical colors, duplicated) and admin.html's
   `.terkonfirmasi` used the same green as my-bookings.html's `.selesai`
   without sharing a definition. Consolidated here (item #8, Fase A) so
   there's one place to change a status color instead of two-plus staying
   in sync by hand. */
.status-pill.terkonfirmasi,
.status-pill.lewat,
.status-pill.disetujui {
  background: var(--success-soft);
  color: var(--success);
}
.status-pill.akan_datang,
.status-pill.menunggu {
  background: var(--primary-soft);
  color: var(--primary);
}
/* "Sedang Berlangsung" (ADR-0018) — a meeting happening right now reads as
   "needs attention"/live, not plain success or plain primary, so this gets
   the accent color instead of reusing either of those. */
.status-pill.berlangsung {
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.status-pill.dibatalkan,
.status-pill.dibatalkan_user,
.status-pill.dibatalkan_admin,
.status-pill.ditolak {
  background: var(--danger-soft);
  color: var(--danger);
}
/* Reschedule status only (never a booking status) — "Tidak Ada" and
   "Selesai" (ADR-0018: a previously-approved reschedule once its booking
   is history) both read as closed/neutral, not an active outcome, so they
   get a muted treatment rather than the vivid green ".disetujui" uses. */
.status-pill.tidak_ada,
.status-pill.selesai {
  background: var(--border);
  color: var(--muted);
}

/* ---------- Pager (Fase D item #9 — shared by pager.js's renderPager(),
   used by admin.html's Data Booking/Log Aktivitas/Pengguna tabs and
   my-bookings.html) ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.pager-info {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- DataTable toolbar (Fase D follow-up, feedback point #4 —
   shared by datatable-ui.js's renderSearchBox()/makeSortableHeader()/
   renderCountInfo(), used everywhere pager.js's .pager is used) ---------- */
.dt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.dt-search-input {
  min-width: 220px;
  flex: 1 1 220px;
}
.dt-count-info {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}
.dt-sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.dt-sortable-th:hover {
  color: var(--primary);
}
.dt-sortable-th:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--primary-soft);
}

/* ---------- Action button groups (data table "Aksi" column) — stacked
   vertically on every DataTable page rather than inline-with-margins, so
   a row with several actions (Edit/Batalkan/Detail, Setujui/Tolak, etc.)
   doesn't force an ultra-wide column. Two selectors because admin.html
   puts the flex directly on the <td class="action-cell">, while
   my-bookings.html wraps its buttons in a <div class="action-btn-group">
   inside the <td> — same layout either way. ---------- */
.action-cell,
.action-btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 120px;
}

/* ---------- Form fields (shared focus-ring treatment) ---------- */
input,
select,
textarea {
  font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.92rem;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- Lightweight loading indicator (spinner) ---------- */
.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 0;
}
.loading-indicator::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Small text-color utilities (used by JS-generated markup so
   dynamic strings don't have to hardcode hex colors — see index.html's
   submit handler and account/list rendering) ---------- */
.text-muted {
  color: var(--muted);
}
.text-danger {
  color: var(--danger);
}
.text-success {
  color: var(--success);
}
