/* =========================================================
   Dayana Inn — papan rak bilik
   Rujukan visual: papan kunci kayu di kaunter penginapan.
   Warna blok = sumber tempahan, supaya staf nampak saluran
   mana yang isi bilik tanpa perlu buka apa-apa.
   ========================================================= */

:root {
  --ink:        #0B2027;
  --ink-2:      #1C3A45;
  --ink-3:      #4A6B76;
  --line:       #DCE4E4;
  --line-soft:  #EDF1F1;
  --paper:      #FBFAF7;
  --surface:    #FFFFFF;

  --brass:      #B8873B;
  --brass-soft: #F5EBD8;

  --src-direct:      #0E7C6B;
  --src-walk_in:     #0E7C6B;
  --src-phone:       #3D6BB3;
  --src-whatsapp:    #3D6BB3;
  --src-booking_com: #1B4DA0;
  --src-agoda:       #B33D77;

  --danger:  #A83232;
  --danger-bg: #FBEDED;

  --row-h: 46px;
  --col-w: 92px;
  --room-w: 132px;

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(11,32,39,.06);
  --shadow-md: 0 8px 28px rgba(11,32,39,.14);
  --shadow-lg: 0 20px 60px rgba(11,32,39,.28);
}

* { box-sizing: border-box; }

/* Atribut [hidden] mesti mengatasi mana-mana display: yang kita tetapkan
   di bawah, kalau tidak skrin yang sepatutnya tersembunyi kekal nampak. */
[hidden] { display: none !important; }


html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- Log masuk ---------- */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% 0%, #16323C 0%, var(--ink) 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-mark, .mark {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  flex: none;
  border-radius: 10px;
  background: var(--ink);
  color: var(--brass-soft);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .02em;
}

.login-brand h1 {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.login-brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.login-card label,
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.login-card input,
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}

.login-card input { margin-bottom: 16px; }

.login-card input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(28,58,69,.10);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

.login-card button[type="submit"]:hover { background: var(--ink-2); }
.login-card button[disabled] { opacity: .6; cursor: progress; }

.form-error {
  margin: 12px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
}

.form-error:empty { margin: 0; min-height: 0; }

/* ---------- Rangka aplikasi ---------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 11px; }
.topbar .mark { width: 36px; height: 36px; font-size: 14px; background: #16323C; }

.topbar-title { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-title strong {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  letter-spacing: -.01em;
}
.topbar-title span { font-size: 12px; color: #93AEB6; }

.topbar-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.btn-primary {
  padding: 9px 15px;
  border: 0;
  border-radius: 8px;
  background: var(--brass);
  color: #21170A;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary:hover { background: #C9964A; }
.btn-block { width: 100%; padding: 13px; }

.btn-ghost {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,.10); }
.btn-sm { padding: 5px 9px; font-size: 12px; }

.btn-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 19px;
  line-height: 1;
}
.btn-icon:hover { background: rgba(255,255,255,.10); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  margin-left: 3px;
  border-left: 1px solid rgba(255,255,255,.18);
  font-size: 13px;
  color: #93AEB6;
}

/* ---------- Jalur statistik ---------- */

.stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  padding: 11px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.stat b {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 19px;
  font-weight: 700;
  margin-right: 6px;
}
.stat span { color: var(--ink-3); }

/* ---------- Papan rak ---------- */

.rack-wrap {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 26px;
  -webkit-overflow-scrolling: touch;
}

.rack-loading {
  padding: 44px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

.rack {
  display: inline-grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-width: 100%;
}

/* baris tajuk tarikh */
.rack-head {
  display: contents;
}

.cell-corner {
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: flex-end;
}

.cell-date {
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line-soft);
  padding: 7px 4px 8px;
  text-align: center;
  background: var(--surface);
}

.cell-date .dow {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.cell-date .dnum {
  display: block;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
}

.cell-date .mon {
  display: block;
  font-size: 10px;
  color: var(--ink-3);
}

.cell-date.is-weekend { background: #F7F5F0; }
.cell-date.is-today .dnum { color: var(--brass); }
.cell-date.is-today {
  box-shadow: inset 0 -3px 0 var(--brass);
}

/* label bilik */
.cell-room {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line-soft);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.cell-room .rnum {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cell-room .beds {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reserved-tag {
  flex: none;
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--brass);
}

.cell-room.is-reserved { background: #FDFBF6; }

/* sel kosong yang boleh diklik */
.cell-slot {
  border: 0;
  border-top: 1px solid var(--line-soft);
  border-left: 1px solid var(--line-soft);
  background: transparent;
  padding: 0;
  min-height: var(--row-h);
  position: relative;
  transition: background .12s;
}

.cell-slot.is-weekend { background: #FAF8F4; }
.cell-slot.is-past { background: repeating-linear-gradient(135deg, #F6F7F7 0 6px, #FBFBFA 6px 12px); }
.cell-slot:hover:not(.is-past) { background: var(--brass-soft); }
.cell-slot:hover:not(.is-past)::after {
  content: '+';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--brass);
  font-size: 17px;
  font-weight: 600;
}

/* blok tempahan — diletak eksplisit dalam grid, bertindih atas sel kosong */
.stay {
  position: relative;
  z-index: 5;
  margin: 4px 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border-radius: 7px;
  border: 0;
  color: #fff;
  text-align: left;
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, filter .12s;
}

.stay:hover { filter: brightness(1.08); transform: translateY(-1px); }

.stay .who {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stay .nights {
  margin-left: auto;
  font-size: 11px;
  opacity: .82;
  flex: none;
}

.stay.src-direct, .stay.src-walk_in { background: var(--src-direct); }
.stay.src-phone, .stay.src-whatsapp { background: var(--src-phone); }
.stay.src-booking_com { background: var(--src-booking_com); }
.stay.src-agoda { background: var(--src-agoda); }

.stay.is-unpaid::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255,255,255,.55);
}

/* ---------- Petunjuk warna ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 12px 18px 22px;
  font-size: 12px;
  color: var(--ink-3);
}

.legend span { display: inline-flex; align-items: center; gap: 7px; }

.dot {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: none;
}

.dot.src-direct { background: var(--src-direct); }
.dot.src-phone { background: var(--src-phone); }
.dot.src-booking_com { background: var(--src-booking_com); }
.dot.src-agoda { background: var(--src-agoda); }
.dot.reserved-key { background: var(--brass); }

/* ---------- Panel gelongsor ---------- */

.sheet { position: fixed; inset: 0; z-index: 60; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11,32,39,.46);
  backdrop-filter: blur(2px);
  animation: fade .16s ease;
}

.sheet-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(430px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in .2s cubic-bezier(.2,.8,.3,1);
}

@keyframes fade { from { opacity: 0 } }
@keyframes slide-in { from { transform: translateX(22px); opacity: .4 } }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 19px;
  font-weight: 700;
}

.sheet-head .btn-icon {
  border-color: var(--line);
  color: var(--ink-3);
  font-size: 22px;
}
.sheet-head .btn-icon:hover { background: var(--line-soft); }

.sheet-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.field { margin-bottom: 15px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.field-hint.warn { color: var(--brass); }

/* butiran tempahan */
.detail-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .03em;
}

.detail-guest {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  margin: 4px 0 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 18px;
  font-size: 14px;
  margin-bottom: 22px;
}

.detail-grid dt {
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding-top: 2px;
}
.detail-grid dd { margin: 0; font-weight: 500; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.btn-danger {
  width: 100%;
  padding: 12px;
  border: 1px solid #E9C9C9;
  border-radius: 9px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 600;
}
.btn-danger:hover { background: #F6DEDE; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 12px 20px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
  max-width: calc(100vw - 32px);
}

.toast.is-error { background: var(--danger); }

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px) } }

/* ---------- Telefon ---------- */

@media (max-width: 720px) {
  :root {
    --col-w: 74px;
    --room-w: 96px;
    --row-h: 44px;
  }

  .topbar { padding: 9px 12px; }
  .topbar-title span { display: none; }
  .user-chip #userName { display: none; }
  .topbar-right { gap: 6px; }

  .rack-wrap { padding: 12px 12px 20px; }
  .stats { gap: 16px; padding: 10px 12px; font-size: 12.5px; }
  .legend { padding: 10px 12px 20px; gap: 6px 14px; }

  .cell-room { padding: 5px 9px; }
  .cell-room .rnum { font-size: 15px; }
  .cell-room .beds { font-size: 10px; }
  .stay .nights { display: none; }
  .stay { padding: 0 7px; }
  .stay .who { font-size: 12px; }

  .sheet-panel { width: 100%; top: auto; height: 92dvh; border-radius: 18px 18px 0 0; }
  @keyframes slide-in { from { transform: translateY(30px); opacity: .5 } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
