/* ============ Tempahan Homestay — gaya mobile-first ============ */
:root {
  --bg: #f3f5f4;
  --card: #ffffff;
  --text: #17201d;
  --muted: #6b7672;
  --line: #e2e7e5;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --success: #15803d;
  --success-soft: #dcfce7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --wa: #1fa855;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413; --card: #182120; --text: #e6efec; --muted: #93a29d; --line: #26312f;
    --primary: #2dd4bf; --primary-ink: #04201d; --primary-soft: #113a35;
    --danger-soft: #3b1414; --warning-soft: #3a2a0b; --success-soft: #0f2e1a; --info-soft: #132447;
    --danger: #f87171; --warning: #fbbf24; --success: #4ade80; --info: #93c5fd;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--primary); text-decoration: none; }
h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h3 { font-size: 1rem; }
small { font-size: .8rem; }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--primary); color: var(--primary-ink);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 12px; }
.topbar h1 { flex: 1; font-size: 1.08rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { color: inherit; display: grid; place-items: center; width: 36px; height: 36px; margin-left: -6px; }
.top-link { color: inherit; font-weight: 600; padding: 6px 12px; border: 1.5px solid currentColor; border-radius: 999px; font-size: .88rem; }

.container { max-width: 640px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabbar a.on { color: var(--primary); }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .plus { width: 40px; height: 30px; border-radius: 10px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; }
.tabbar .plus svg { stroke-width: 2.6; }

/* ---------- Cards, alerts, badges ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.empty { text-align: center; color: var(--muted); padding: 28px 14px; }
.alert { padding: 11px 14px; border-radius: 12px; font-weight: 500; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.chip {
  display: inline-flex; align-items: center; font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  color: #fff; background: var(--c, #2563eb); white-space: nowrap;
}
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); margin-right: 6px; flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost-danger { color: var(--danger); border-color: var(--danger-soft); background: transparent; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .84rem; border-radius: 9px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; font-size: 1.6rem; color: var(--text); border-radius: 12px; }
.icon-btn:active { background: var(--bg); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form .card { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  font: inherit; font-size: 16px; /* elak zoom auto di iPhone */
  color: var(--text); background: var(--card);
  border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 12px; width: 100%; min-height: 44px;
}
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
input[type=color] { padding: 4px; height: 44px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.row2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.row2 > *, label { min-width: 0; }
input[type=date] { -webkit-appearance: none; appearance: none; min-width: 0; display: block; }
.input-group { display: flex; }
.input-group input { border-radius: 11px 0 0 11px; }
.input-group select { width: 72px; border-radius: 0 11px 11px 0; border-left: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 4px; }
.seg label, .h-picker label { position: relative; }
.seg input, .h-picker input { position: absolute; inset: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.seg label { margin: 0; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 10px; font-size: .95rem; color: var(--muted); }
.seg input:checked + span { background: var(--primary); color: var(--primary-ink); }

.h-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.h-picker label { margin: 0; }
.h-picker span { display: flex; align-items: center; padding: 9px 14px; border-radius: 11px; border: 1.5px solid var(--line); color: var(--text); font-size: .92rem; }
.h-picker input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.h-picker input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary-soft); }

.avail { padding: 10px 12px; border-radius: 10px; font-weight: 600; font-size: .9rem; }
.avail.ok { background: var(--success-soft); color: var(--success); }
.avail.bad { background: var(--danger-soft); color: var(--danger); }

.summary { background: var(--bg); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; }
.summary div { display: flex; justify-content: space-between; }
.summary .total { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; font-size: 1.1rem; }
.summary .total b { color: var(--primary); }
.quick-pay { display: flex; gap: 8px; flex-wrap: wrap; }

.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 6px);
  z-index: 5; padding-top: 4px;
}
.sticky-actions .btn { box-shadow: 0 6px 18px rgba(15,118,110,.25); min-height: 50px; font-size: 1.02rem; }

#bookingForm.is-block .only-booking { display: none; }
#bookingForm:not(.is-block) .only-block { display: none; }

/* ---------- Kalendar ---------- */
.today-strip { display: flex; flex-direction: column; gap: 6px; }
.today-item { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; color: var(--text); }
.today-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.tag-in { background: var(--success-soft); color: var(--success); }
.tag-out { background: var(--warning-soft); color: var(--warning); }

.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.fchip { display: inline-flex; align-items: center; white-space: nowrap; padding: 7px 13px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: .86rem; font-weight: 600; }
.fchip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.fchip.on .dot { box-shadow: 0 0 0 2px var(--bg); }

.cal-card { padding: 8px 8px 12px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav.flat { padding: 4px 6px; }
.month-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-head div { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: 6px 0 4px; }
.cal-day {
  appearance: none; border: 1.5px solid transparent; background: var(--bg); border-radius: 10px;
  min-height: 56px; padding: 5px 3px 6px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  font: inherit; color: var(--text); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.cal-day.empty { background: transparent; pointer-events: none; }
.cal-day .num { font-size: .9rem; font-weight: 600; }
.cal-day.is-weekend .num { color: var(--danger); }
.cal-day.is-past { opacity: .5; }
.cal-day.is-today { border-color: var(--primary); }
.cal-day.is-today .num { background: var(--primary); color: var(--primary-ink); border-radius: 999px; padding: 0 6px; }
.cal-day.is-full { background: color-mix(in srgb, var(--danger) 10%, var(--card)); }
.cal-day.selected { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.bars { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0 2px; }
.bar { display: block; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--c) 9%, transparent); }
.bar.booked { background: var(--c); }
.bar.quote { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.bar.block { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); }
.legend { display: flex; justify-content: center; gap: 14px; font-size: .74rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 5px; }
.lg { width: 16px; height: 6px; border-radius: 3px; display: inline-block; --c: var(--primary); }
.lg.booked { background: var(--c); }
.lg.quote { box-shadow: inset 0 0 0 1.5px var(--c); }
.lg.block { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); }

.day-panel h3 { display: flex; justify-content: space-between; align-items: center; }
.slot { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--text); }
.slot:first-of-type { border-top: 0; }
.slot .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.slot .info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .state-free { color: var(--success); font-weight: 700; }
.slot .go { color: var(--muted); }

/* ---------- Senarai ---------- */
.search-bar { display: flex; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; }
.stats b { font-size: 1.1rem; }
.stats span { font-size: .68rem; color: var(--muted); font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 8px; }
.booking-card { display: flex; gap: 12px; color: var(--text); padding: 12px; border-left: 4px solid var(--c); }
.bc-date { width: 66px; flex: none; display: flex; flex-direction: column; font-size: .85rem; }
.bc-date b { font-size: 1rem; }
.bc-date span { color: var(--muted); }
.bc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bc-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-top { display: flex; gap: 6px; align-items: center; }
.is-cancelled { opacity: .55; }
.is-cancelled strong { text-decoration: line-through; }
.row-link { display: flex; align-items: center; gap: 12px; color: var(--text); }
.row-link.plain { padding: 0; }

/* ---------- Butiran ---------- */
.detail-head { border-top: 5px solid var(--c); }
.dh-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.detail-head h2 { font-size: 1.3rem; margin-bottom: 2px; }
.contact { margin: 0 0 10px; }
.dates { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px; }
.dates > div { display: flex; flex-direction: column; }
.dates > div:last-child { text-align: right; }
.dates small { color: var(--muted); }
.dates .nights { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--primary); line-height: 1; }
.dates .nights small { display: block; font-size: .7rem; font-weight: 600; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid .btn-wa { grid-column: 1 / -1; }
.action-grid .btn:last-child:nth-child(even) { grid-column: 1 / -1; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv .strong { color: var(--text); font-weight: 700; }
.neg { color: var(--danger); }
.pos { color: var(--success); }

.pay-list { list-style: none; margin: 0 0 8px; padding: 0; }
.pay-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pay-list li > div:first-child { display: flex; flex-direction: column; }
.pay-list .badge { align-self: flex-start; margin: 2px 0; }
.pay-actions { display: flex; gap: 6px; }
.add-pay summary { cursor: pointer; font-weight: 700; color: var(--primary); padding: 8px 0; list-style: none; }
.add-pay summary::-webkit-details-marker { display: none; }
.add-pay[open] summary { margin-bottom: 6px; }
.inline-form { flex-direction: row; margin-bottom: 8px; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.log { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }

/* ---------- Menu & login ---------- */
.user-card { display: flex; align-items: center; gap: 12px; }
.user-card > div:last-child { display: flex; flex-direction: column; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; flex: none; }
.avatar.sm { width: 36px; height: 36px; font-size: .95rem; }
.menu-list { padding: 4px 0; }
.menu-list a { display: block; padding: 14px 16px; color: var(--text); border-bottom: 1px solid var(--line); font-weight: 500; }
.menu-list a:last-child { border-bottom: 0; }

.auth-box { max-width: 380px; width: 100%; margin: 24px auto 0; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.auth-box .form { text-align: left; }
.brand-mark { font-size: 2.6rem; }

@media (min-width: 560px) {
  .cal-day { min-height: 72px; }
  .bar { height: 7px; }
}
