/* Dubai Hostel admin.
   Data colours follow the dataviz reference palette: bed states use the fixed
   status palette (always with an icon + label), the occupancy meter uses one
   sequential hue. Burgundy is brand chrome only - never a data colour. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --brand: #5c1024;
  --brand-hover: #7a1b31;
  --brand-ink: #ffffff;
  --focus: #2a78d6;

  --accent: #2a78d6;        /* sequential blue, step 450 */
  --accent-track: #cde2fb;  /* same ramp, step 100 */

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --success-text: #006300;

  --tint-vacant: rgba(12, 163, 12, 0.08);
  --tint-reserved: rgba(250, 178, 25, 0.16);
  --tint-occupied: rgba(11, 11, 11, 0.045);
  --tint-overdue: rgba(208, 59, 59, 0.09);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-raised: #222220;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --brand: #8a2440;
    --brand-hover: #a12d4c;
    --focus: #3987e5;
    --accent: #3987e5;
    --accent-track: #184f95;
    --success-text: #0ca30c;
    --tint-vacant: rgba(12, 163, 12, 0.14);
    --tint-reserved: rgba(250, 178, 25, 0.14);
    --tint-occupied: rgba(255, 255, 255, 0.05);
    --tint-overdue: rgba(208, 59, 59, 0.18);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.sep { border: 0; border-top: 1px solid var(--hairline); margin: 4px 0; }
.small { font-size: 0.85rem; }
.num { font-variant-numeric: tabular-nums; }
.loading, .empty { color: var(--muted); padding: 24px 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: var(--brand); color: var(--brand-ink);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.14); font-weight: 700; font-size: 0.85rem;
}
.brand-text { font-weight: 650; white-space: nowrap; }
.brand-text small { font-weight: 500; opacity: 0.72; margin-left: 4px; }
.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 7px 12px; border-radius: 8px; text-decoration: none; white-space: nowrap;
  color: rgba(255, 255, 255, 0.82); font-weight: 550;
}
.nav a:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.18); color: #fff; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

main { max-width: 1180px; margin: 0 auto; padding: 24px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface-raised); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--baseline); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--critical); border-color: rgba(208, 59, 59, 0.45); }
.btn-danger:hover:not(:disabled) { background: rgba(208, 59, 59, 0.08); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 0.85rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 0.78rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-error {
  color: var(--critical); background: rgba(208, 59, 59, 0.08); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 0.88rem; margin: 0;
}

.check-row { display: flex; align-items: center; gap: 9px; font-size: 0.9rem; cursor: pointer; }
.check-row input { width: 18px; min-height: 18px; height: 18px; flex: none; accent-color: var(--brand); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--hairline); }
.segmented button {
  border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 0.88rem;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--ink-2);
}
.segmented button[aria-pressed="true"] { background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 12px; }

/* ---------- stat tiles (label · value · caption) ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { font-size: 0.82rem; color: var(--ink-2); font-weight: 550; }
.tile-value { font-size: 1.75rem; font-weight: 650; line-height: 1.2; margin-top: 4px; letter-spacing: -0.01em; }
.tile-caption { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

.hero-row { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 12px; }
.hero { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.hero-figure { font-size: 3.5rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.hero-sub { color: var(--ink-2); margin-top: 6px; }

/* meter: fill + a lighter step of the same ramp as the track */
.meter { height: 10px; border-radius: 999px; background: var(--accent-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); min-width: 0; }
.meter-row { display: grid; grid-template-columns: 150px 1fr 250px; align-items: center; gap: 16px; padding: 10px 0; }
.meter-row + .meter-row { border-top: 1px solid var(--hairline); }
.meter-row .label { font-weight: 600; }
.meter-row .figures { text-align: right; font-size: 0.88rem; color: var(--ink-2); }

/* ---------- state badges: colour + icon + label, never colour alone ---------- */
.state {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 650;
  color: var(--ink); white-space: nowrap;
}
.state svg { width: 14px; height: 14px; flex: none; }
.state-vacant svg   { color: var(--good); }
.state-reserved svg { color: #b87e00; }
.state-occupied svg { color: var(--ink-2); }
.state-overdue svg  { color: var(--critical); }
.state-inactive     { color: var(--muted); }
@media (prefers-color-scheme: dark) { .state-reserved svg { color: var(--warning); } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
/* on a phone, scroll the table sideways rather than breaking names mid-word */
@media (max-width: 860px) { .table-wrap table { min-width: 760px; } .table-wrap td { white-space: nowrap; } }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
th { font-size: 0.76rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--tint-occupied); }
.balance-due { color: var(--ink); font-weight: 650; }
.balance-due::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--critical); margin-right: 6px; vertical-align: middle; }
.balance-ok { color: var(--success-text); }
.balance-pending { color: var(--ink-2); }

/* ---------- room board ---------- */
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.rooms { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.room-head .meta { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.units { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
.unit {
  position: relative; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; min-height: 84px;
  padding: 10px 10px 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--tint-occupied);
}
.unit::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ink-2); }
.unit:hover { border-color: var(--baseline); }
.unit-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.unit-label { font-weight: 700; }
.unit-guest { font-size: 0.82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-dates { font-size: 0.76rem; color: var(--muted); }
.unit.is-vacant   { background: var(--tint-vacant); }
.unit.is-vacant::before   { background: var(--good); }
.unit.is-reserved { background: var(--tint-reserved); }
.unit.is-reserved::before { background: var(--warning); }
.unit.is-overdue  { background: var(--tint-overdue); }
.unit.is-overdue::before  { background: var(--critical); }
.unit.is-inactive { background: transparent; opacity: 0.6; }
.unit.is-inactive::before { background: var(--baseline); }

/* ---------- guests / detail ---------- */
.search { max-width: 360px; }
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--hairline); color: var(--ink-2); }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.pick {
  display: flex; justify-content: space-between; gap: 8px; text-align: left; font: inherit; cursor: pointer;
  padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink);
}
.pick[aria-pressed="true"] { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: -1px; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 0.9rem; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 550; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }

/* ---------- dialog ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink);
}
.dialog::backdrop { background: rgba(10, 10, 10, 0.45); }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--hairline); }
.dialog-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 20px 18px; border-top: 1px solid var(--hairline); }
.dialog-body > .segmented { align-self: flex-start; }
.dialog-body .segmented + div, .dialog-body div > .segmented { margin-bottom: 12px; }
.icon-btn { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 1.4rem; line-height: 1; padding: 2px 6px; border-radius: 6px; }

/* ---------- toasts ---------- */
/* ---------- booking history ---------- */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.history li { border-left: 2px solid var(--hairline); padding: 0 0 0 12px; }
.history-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.history-tag { font-size: 0.78rem; font-weight: 650; }
.tag-created { color: var(--ink); }
.tag-checked_in { color: var(--success-text); }
.tag-checked_out { color: var(--ink-2); }
.tag-cancelled { color: var(--critical); }
.tag-payment { color: var(--success-text); }
.tag-edited { color: var(--ink-2); }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--page); padding: 10px 14px; border-radius: 10px; font-size: 0.9rem; max-width: 340px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--critical); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero-row, .detail-grid { grid-template-columns: 1fr; }
  .meter-row { grid-template-columns: 100px 1fr; }
  .meter-row .figures { grid-column: 1 / -1; text-align: left; margin-top: -4px; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; margin-left: 0; }
  .topbar #logout { margin-left: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .rooms { grid-template-columns: 1fr; }
  .hero-figure { font-size: 3rem; }
}
