/* ═══════════════════════════════════════════════════
   Hotel PMS — Main Stylesheet
   Tablet-first, touch-friendly
═══════════════════════════════════════════════════ */

:root {
  --primary:       #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37,99,235,.12);
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --warning:       #d97706;

  --bg:            #ffffff;
  --bg-page:       #f1f5f9;
  --bg-card:       #ffffff;
  --border:        #e2e8f0;
  --border-hover:  #cbd5e1;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --sidebar-w:     260px;
  --topbar-h:      56px;
  --row-h:         52px;
  --radius:        10px;
  --radius-lg:     14px;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg-page); color: var(--text);
       min-height: 100vh; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
textarea, input, select, button { font-family: inherit; }

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100dvh;
  background: var(--bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(calc(-1 * var(--sidebar-w)));
  transition: transform .22s ease;
  z-index: 300; overflow-y: auto;
}
.sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.12); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 299;
}
.sidebar-overlay.show { display: block; }
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo { max-height: 48px; max-width: 140px; margin-bottom: 8px; display: block; }
.sidebar-hotel { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.3; }
.sidebar-user  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav { list-style: none; padding: 8px 0; flex: 1; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; font-size: 15px; color: var(--text);
  border-radius: 0; transition: background .12s;
}
.sidebar-nav li a:hover { background: var(--bg-page); text-decoration: none; }
.sidebar-nav li a.active {
  background: var(--primary-light); color: var(--primary); font-weight: 500;
  border-right: 3px solid var(--primary);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.nav-sep { height: 1px; background: var(--border); margin: 6px 16px; }

/* ── Top bar ────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  z-index: 200;
}
.menu-btn {
  font-size: 22px; background: none; border: none; cursor: pointer;
  color: var(--text); padding: 8px; border-radius: 8px; line-height: 1;
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center;
}
.menu-btn:hover { background: var(--bg-page); }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-date  { font-size: 13px; color: var(--text-muted); }

/* ── Main content ───────────────────────────────── */
.main-content {
  margin-top: var(--topbar-h);
  padding: 20px 16px 80px;
  min-height: calc(100dvh - var(--topbar-h));
}

/* ── Page header ────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; flex: 1; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-header-right   { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
  text-decoration: none; min-height: 40px;
}
.btn:hover { background: var(--bg-page); border-color: var(--border-hover); text-decoration: none; }
.btn:active { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-secondary { background: var(--bg-page); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-large { min-height: 52px; font-size: 17px; padding: 14px 24px; }
.btn-sm  { padding: 7px 12px; font-size: 13px; min-height: 34px; }
.btn-xs  { padding: 4px 8px;  font-size: 11px; min-height: 26px; }

/* ── Forms ──────────────────────────────────────── */
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.req { color: var(--danger); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 16px; margin-bottom: 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.form-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.form-card-title { font-size: 16px; font-weight: 600; }

/* ── Cards ──────────────────────────────────────── */
.detail-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.detail-card-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 16px; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 6px 0; font-size: 14px; vertical-align: top; }
.info-table td:first-child { color: var(--text-muted); width: 110px; font-size: 13px; }

/* ── Tables ─────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead { background: var(--bg-page); }
.data-table th { padding: 12px 14px; text-align: left; font-size: 12px; font-weight: 600;
                  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
                  white-space: nowrap; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-page); }

/* ── Permissions table ──────────────────────────── */
.perm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.perm-table th, .perm-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.perm-table th { background: var(--bg-page); font-size: 12px; font-weight: 600;
                  text-transform: uppercase; color: var(--text-muted); }
.perm-group-row td { background: var(--bg-page); font-size: 12px; font-weight: 600;
                      text-transform: uppercase; color: var(--text-muted); letter-spacing: .05em;
                      border-top: 2px solid var(--border); }
.perm-checkbox { width: 20px; height: 20px; cursor: pointer; }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; white-space: nowrap;
}
.badge-pending    { background: #fef9c3; color: #854d0e; }
.badge-confirmed  { background: #dbeafe; color: #1d4ed8; }
.badge-checked_in { background: #dcfce7; color: #15803d; }
.badge-checked_out{ background: #e0e7ff; color: #4338ca; }
.badge-cancelled  { background: #fee2e2; color: #b91c1c; }
.badge-method     { background: var(--bg-page); color: var(--text-muted); }

/* ── Alerts ─────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: var(--success-light); border: 1px solid #86efac; color: #15803d; }
.alert-error   { background: var(--danger-light);  border: 1px solid #fca5a5; color: #b91c1c; }

/* ── Filter bar ─────────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar .form-input, .filter-bar .form-select { max-width: 260px; flex: 1; }

/* ── Calendar ───────────────────────────────────── */
.cal-toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.cal-view-btns { display: flex; gap: 4px; }
.cal-nav       { display: flex; gap: 4px; }
.cal-date-label{ font-size: 15px; font-weight: 600; flex: 1; }

.cal-outer   { overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg); }
.cal-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
.cal-grid    { display: grid; position: relative; }
.cal-header-row { background: var(--bg-page); }

/* ── Calendar room column ───────────────────────── */
/* The JS-rendered room <td> uses inline styles on a <b> tag.       */
/* These classes are kept only for the old PHP-rendered cal headers. */
.cal-room-header {
  background: var(--bg-page);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  position: sticky;
  left: 0;
  z-index: 10;
}

.cal-date-header {
  padding: 6px 4px; font-size: 11px; text-align: center; color: var(--text-muted);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cal-date-header.today { color: var(--primary); font-weight: 700; background: var(--primary-light); }
.cal-date-header.weekend { background: #fafafa; }
.cal-cell {
  height: var(--row-h); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  min-width: 44px; cursor: pointer; transition: background .1s;
}
.cal-cell:hover { background: var(--primary-light); }
.cal-cell.today-col { background: rgba(37,99,235,.04); }
.cal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.cal-block {
  position: absolute; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 500;
  padding: 0 8px; display: flex; align-items: center; cursor: pointer;
  pointer-events: all; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border: 2px solid rgba(255,255,255,.3); user-select: none;
  transition: opacity .1s, box-shadow .1s;
}
.cal-block:hover { opacity: .88; box-shadow: 0 2px 8px rgba(0,0,0,.25); z-index: 20; }
.cal-block.dragging { opacity: .55; }

/* ── Modal ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 400;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--bg-card); border-radius: var(--radius-lg);
  width: min(520px, 96vw); max-height: 90dvh; overflow-y: auto;
  z-index: 401; box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 16px;
}
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body   { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

/* ── Payment / Deposit ──────────────────────────── */
.payment-summary {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; margin-bottom: 16px;
}
.payment-stat { text-align: center; background: var(--bg-page); border-radius: var(--radius); padding: 12px 8px; }
.payment-stat-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.payment-stat-value { font-size: 18px; font-weight: 700; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }

.amount-display {
  font-size: 36px; font-weight: 700; text-align: center; padding: 16px;
  background: var(--bg-page); border-radius: var(--radius); margin-bottom: 12px;
  letter-spacing: .05em; min-height: 72px; display: flex; align-items: center; justify-content: center;
}

/* ── Numpad ─────────────────────────────────────── */
.numpad {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px;
}
.numpad-key {
  height: 58px; font-size: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; user-select: none; transition: background .1s;
}
.numpad-key:hover  { background: var(--bg-page); }
.numpad-key:active { background: var(--primary-light); }

/* ── Guest search dropdown ──────────────────────── */
.guest-search-wrap { position: relative; }
.guest-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 220px; overflow-y: auto; z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.guest-option {
  padding: 10px 14px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--border);
}
.guest-option:hover { background: var(--primary-light); }
.guest-option small { color: var(--text-muted); font-size: 12px; margin-left: 6px; }

/* ── Empty state ────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 15px;
}

/* ── Misc ───────────────────────────────────────── */
code { font-family: monospace; background: var(--bg-page); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ── Responsive ─────────────────────────────────── */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); box-shadow: none; }
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: var(--sidebar-w); }
  .topbar { left: var(--sidebar-w); }
  .menu-btn { display: none; }
}
@media (max-width: 600px) {
  .page-title { font-size: 18px; }
  .btn-large { font-size: 15px; min-height: 48px; }
  .form-row { grid-template-columns: 1fr; }
  .payment-summary { grid-template-columns: 1fr 1fr; }
  /* NOTE: no font-size override for cal-room-header here —
     room numbers are now rendered with inline styles in calendar.js */
}

/* Force calendar room number size — overrides table font inheritance */
#calTbl td b {
    font-size: 20px !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    line-height: 1.1 !important;
    display: block !important;
}