/* =====================================================================
   ระบบบริหารจัดการโรงแรม — สไตล์หลัก (Bootstrap 5.3 + ธีมสว่าง/มืด)
   ===================================================================== */
:root {
  --brand: #14213d;
  --brand-2: #1f3a6e;
  --accent: #fca311;
  --sidebar-w: 248px;
  --bs-font-sans-serif: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-primary: #2155cd;
  --bs-primary-rgb: 33, 85, 205;
  --bs-body-bg: #f4f6fa;
}
[data-bs-theme="dark"] {
  --bs-body-bg: #0f1520;
  --bs-tertiary-bg: #161e2c;
}
body { font-size: .94rem; background: var(--bs-body-bg); }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: "Prompt", var(--bs-font-sans-serif); font-weight: 600; }
.btn-primary { --bs-btn-bg: #2155cd; --bs-btn-border-color: #2155cd; --bs-btn-hover-bg: #1a46ac; --bs-btn-hover-border-color: #1a46ac; }
.card { border: 0; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); border-radius: .75rem; }
[data-bs-theme="dark"] .card { background: var(--bs-tertiary-bg); box-shadow: none; border: 1px solid rgba(255,255,255,.06); }
.card-header { background: transparent; border-bottom: 1px solid var(--bs-border-color-translucent); padding: .8rem 1rem; }
.card-footer { background: transparent; }
.skip-link:focus { position: fixed; top: .5rem; left: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.text-pre { white-space: pre-line; }

/* ---------- Layout ---------- */
.app-sidebar {
  background: linear-gradient(180deg, var(--brand), #0d1730);
  color: #cfd6e6;
  width: var(--sidebar-w);
}
@media (min-width: 992px) {
  .app-sidebar { position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 1030; }
  .app-main { margin-left: var(--sidebar-w); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .75rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand strong { display: block; color: #fff; font-size: .98rem; line-height: 1.2; }
.sidebar-brand small { color: #9aa6c0; font-size: .74rem; }
.sidebar-nav { padding: .5rem .6rem 2rem; }
.nav-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #7f8bab; padding: 1rem .6rem .35rem; }
.sidebar-nav .nav-link { color: #cfd6e6; border-radius: .5rem; padding: .5rem .65rem; display: flex; gap: .65rem; align-items: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--accent); color: #14213d; font-weight: 600; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .5rem;
  height: 60px; padding: 0 1rem;
  background: rgba(var(--bs-body-bg-rgb), .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bs-border-color-translucent);
}
.topbar-title { font-weight: 600; }
.btn-icon { border: 0; background: transparent; padding: .35rem .5rem; color: inherit; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: 0; background: transparent; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-2); color: #fff; display: inline-grid; place-items: center; font-weight: 600; }
.app-content { padding: 1.25rem; min-height: calc(100vh - 110px); }
.app-footer { padding: .75rem 1.25rem; font-size: .78rem; color: var(--bs-secondary-color); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 20%, #1f3a6e, #14213d 60%); }
.auth-card { width: 100%; max-width: 400px; background: var(--bs-body-bg); border-radius: 1rem; padding: 2rem; box-shadow: 0 20px 50px rgba(0,0,0,.3); }

/* ---------- Stat cards ---------- */
.stat-card { display: flex; gap: .9rem; align-items: center; padding: 1rem; background: var(--bs-body-bg); border-radius: .75rem; box-shadow: 0 1px 3px rgba(16,24,40,.08); height: 100%; }
[data-bs-theme="light"] .stat-card { background: #fff; }
[data-bs-theme="dark"] .stat-card { background: var(--bs-tertiary-bg); border: 1px solid rgba(255,255,255,.06); }
.stat-card.compact { padding: .8rem 1rem; }
.stat-icon { width: 48px; height: 48px; border-radius: .75rem; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-label { font-size: .8rem; color: var(--bs-secondary-color); }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-family: "Prompt", sans-serif; }
.stat-sub { font-size: .75rem; color: var(--bs-secondary-color); }
.legend { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--bs-secondary-color); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Room board ---------- */
.building-label { font-size: .95rem; font-weight: 600; font-family: "Prompt", sans-serif; padding-bottom: .3rem; border-bottom: 1px solid var(--bs-border-color); margin: 1.1rem 0 .2rem; }
.building-label:first-child { margin-top: 0; }
.floor-label { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); margin: .6rem 0 .4rem; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.room-tile { display: block; padding: .55rem .65rem; border-radius: .6rem; text-decoration: none; color: #fff; min-height: 84px; transition: transform .1s, box-shadow .1s; }
.room-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.15); color: #fff; }
.room-no { font-size: 1.15rem; font-weight: 700; font-family: "Prompt", sans-serif; }
.room-type { font-size: .68rem; background: rgba(255,255,255,.22); padding: 0 .35rem; border-radius: .3rem; }
.room-info { font-size: .78rem; margin-top: .2rem; }
.status-vacant_clean { background: #198754; }
.status-vacant_dirty { background: #e0a100; color: #212529; }
.status-vacant_dirty:hover { color: #212529; }
.status-vacant_dirty .room-type { background: rgba(0,0,0,.1); }
.status-occupied { background: #2155cd; }
.status-arrival { background: #0aa2c0; }
.status-ooo { background: #c0392b; background-image: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(255,255,255,.08) 6px, rgba(255,255,255,.08) 12px); }

/* ---------- Forms / lists ---------- */
.search-results { z-index: 1050; max-height: 320px; overflow-y: auto; }
.selected-guest { padding: .6rem .8rem; border-radius: .5rem; background: var(--bs-success-bg-subtle); }
.nights-box { padding: .375rem .75rem; border-radius: .375rem; background: var(--bs-tertiary-bg); text-align: center; font-weight: 600; }
.room-picker { max-height: 420px; overflow-y: auto; border: 1px solid var(--bs-border-color-translucent); border-radius: .5rem; }
.room-picker thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 1; }
.room-picker tr.is-selected td { background: var(--bs-primary-bg-subtle); }
.summary-list { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; }
.summary-list dt { font-weight: 400; color: var(--bs-secondary-color); }
.summary-list dd { margin: 0; text-align: right; }
.info-label { font-size: .75rem; color: var(--bs-secondary-color); }
.row-link { cursor: pointer; }
.small-dl dt { font-weight: 500; color: var(--bs-secondary-color); }
.json-box { font-size: .72rem; background: var(--bs-tertiary-bg); padding: .5rem; border-radius: .4rem; max-height: 240px; overflow: auto; margin: 0; }

/* folio */
#items-table.hide-void tr.is-void { display: none; }
#items-table tr.is-void td { text-decoration: line-through; color: var(--bs-tertiary-color); }

/* ---------- Product grid (ลงบิล) ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.product-item { border: 1px solid var(--bs-border-color); border-radius: .6rem; padding: .7rem; }
.product-item.has-qty { border-color: var(--bs-primary); background: var(--bs-primary-bg-subtle); }
.qty-stepper input { max-width: 70px; }

/* ---------- Rack ---------- */
.rack-wrap { overflow: auto; max-height: calc(100vh - 220px); }
.rack { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .82rem; }
.rack th, .rack td { border-right: 1px solid var(--bs-border-color-translucent); border-bottom: 1px solid var(--bs-border-color-translucent); }
.rack thead th { position: sticky; top: 0; background: var(--bs-body-bg); z-index: 2; text-align: center; min-width: 54px; padding: .3rem .2rem; font-weight: 500; line-height: 1.15; }
.rack .rack-room { position: sticky; left: 0; background: var(--bs-body-bg); z-index: 1; min-width: 92px; padding: .35rem .6rem; text-align: left; white-space: nowrap; }
.rack thead .rack-room { z-index: 3; }
.rack .rack-group > * { background: var(--bs-tertiary-bg); font-weight: 600; padding: .3rem .6rem; }
.rack .is-weekend { background: var(--bs-tertiary-bg); }
.rack thead th.is-today { background: var(--accent); color: #14213d; }
.rack td.is-today { background: rgba(252, 163, 17, .08); }
.rack td.is-ooo { background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(192,57,43,.12) 5px, rgba(192,57,43,.12) 10px); }
.rack-cell { height: 38px; padding: 3px 2px; }
.rack-bar { display: block; height: 100%; border-radius: 6px; color: #fff; text-decoration: none; padding: 0 .5rem; line-height: 32px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.rack-bar.bg-warning { color: #212529; }
.rack-bar.clipped { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.rack-bar:hover { filter: brightness(1.1); color: #fff; }
.rack-empty { display: block; height: 100%; border-radius: 6px; }
.rack-empty:hover { background: var(--bs-primary-bg-subtle); outline: 1px dashed var(--bs-primary); }

/* ---------- Permission table ---------- */
.perm-table thead th { background: var(--bs-body-bg); min-width: 100px; }

/* ---------- Receipt ---------- */
.receipt-paper { position: relative; background: #fff; color: #212529; max-width: 820px; margin: 0 auto; padding: 2rem 2.25rem; border-radius: .5rem; box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.receipt-paper .text-body-secondary { color: #6c757d !important; }
.receipt-paper .table { --bs-table-bg: transparent; --bs-table-color: #212529; border-color: #dee2e6; }
.receipt-box { border: 1px solid #dee2e6; border-radius: .4rem; padding: .6rem .3rem; margin-left: 0; margin-right: 0; }
.signature-line { border-bottom: 1px dotted #333; height: 2.5rem; margin-bottom: .3rem; }
.void-stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-20deg); font-size: 5rem; font-weight: 800; color: rgba(220, 53, 69, .3); border: 8px solid rgba(220, 53, 69, .3); padding: 0 2rem; border-radius: 1rem; pointer-events: none; }

/* ---------- Public room board (ก่อนเข้าสู่ระบบ) ---------- */
.public-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; }
.public-content { padding: 1.25rem; max-width: 1600px; margin: 0 auto; min-height: calc(100vh - 110px); }
.public-stat { border-radius: .75rem; padding: 1rem 1.1rem; height: 100%; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
.public-stat-light { background: #fff; }
[data-bs-theme="dark"] .public-stat-light { background: var(--bs-tertiary-bg); }
.public-stat-label { font-size: .85rem; font-weight: 500; }
.public-stat-value { font-size: 2.4rem; font-weight: 700; line-height: 1.1; font-family: "Prompt", sans-serif; }
.public-tile { cursor: default; }
.public-tile:hover { transform: none; box-shadow: none; }

/* ---------- Reports ---------- */
.print-only { display: none; }
.report-card { transition: transform .1s, box-shadow .1s; }
.report-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,24,40,.12); }
.report-scroll { max-height: 420px; overflow-y: auto; }
.report-table th { white-space: nowrap; }
.bar-list { display: grid; gap: .45rem; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: .6rem; align-items: center; font-size: .85rem; }
.bar-track { background: var(--bs-tertiary-bg); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-fill { background: var(--bs-primary); height: 100%; border-radius: 4px; }
.bar-value { text-align: right; white-space: nowrap; }
.avail-table th, .avail-table td { min-width: 44px; }
.avail-table thead th.is-today { background: var(--accent); color: #14213d; }
.avail-ok { background: rgba(25, 135, 84, .12); }
.avail-low { background: rgba(255, 193, 7, .25); }
.avail-none { background: rgba(220, 53, 69, .18); color: var(--bs-danger); }
.checklist-table td { height: 2rem; }
.manage-row > td { background: var(--bs-tertiary-bg); }

/* ---------- Coupons ---------- */
.coupon-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .75rem; }
.coupon { background: #fff; color: #212529; border: 2px dashed #6c757d; border-radius: .6rem; padding: .8rem 1rem; break-inside: avoid; }
.coupon-title { font-family: "Prompt", sans-serif; font-weight: 600; font-size: 1.15rem; text-align: center; margin: .35rem 0 .5rem; color: #14213d; }
.coupon-room { font-size: 1.6rem; font-weight: 700; font-family: "Prompt", sans-serif; line-height: 1; }
.coupon-note { font-size: .75rem; color: #6c757d; border-top: 1px dotted #adb5bd; margin-top: .5rem; padding-top: .35rem; }
.slip-paper { max-width: 680px; }

@media print {
  .print-only { display: inline; }
  .page-break-before { break-before: page; }
  .report-scroll { max-height: none; overflow: visible; }
  .coupon-sheet { grid-template-columns: repeat(2, 1fr); gap: 4mm; }
  .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .avail-ok, .avail-low, .avail-none, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .app-sidebar, .app-topbar, .app-footer, .no-print, .page-head .btn, .alert { display: none !important; }
  .app-main { margin: 0 !important; }
  .app-content { padding: 0 !important; }
  body { background: #fff !important; font-size: 12px; }
  .receipt-paper { box-shadow: none; padding: 0; max-width: none; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  @page { size: A4; margin: 12mm; }
}
