/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --danger: #EF4444;
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface2: #F8FAFC;
  /* Single grid line color — used everywhere */
  --gl: #D1D9E6;
  --gl-strong: #94A3B8;
  --text: #0F172A;
  --text-muted: #64748B;
  --today-bg: #DBEAFE;
  --weekend-bg: #FFFBEB;
  --success: #10B981;

  --label-w: 82px;
  --day-w: 38px;
  --row-h: 50px;
  --head-h: 52px;   /* header = day row only (no month row) */
  --day-h: 52px;
  --radius: 10px;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }

/* ─── Views ─────────────────────────────────────────────────── */
.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* Login view stays locked */
#login-view { height: 100dvh; overflow: hidden; }
/* App view scrolls vertically so feed is accessible below grid */
#app-view { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.hidden { display: none !important; }

/* ─── LOGIN ─────────────────────────────────────────────────── */
#login-view {
  background: #0F172A;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 28px 32px;
  width: 100%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-hotel-name {
  font-size: 22px; font-weight: 700; text-align: center;
  color: var(--text); margin-bottom: 28px;
}

/* ─── Form elements ──────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 6px;
}
.label-hint {
  font-size: 10px; font-weight: 500; text-transform: none;
  letter-spacing: 0; color: var(--primary); margin-left: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--gl);
  border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  outline: none; transition: border-color 0.15s;
  appearance: none; -webkit-appearance: none;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748B' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.form-group textarea { resize: vertical; min-height: 64px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; padding: 13px;
  background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 600;
  border-radius: var(--radius);
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-danger {
  padding: 11px 16px; background: #FEE2E2; color: var(--danger);
  font-size: 14px; font-weight: 600; border-radius: var(--radius);
  transition: background 0.15s;
}
.btn-danger:hover { background: #FECACA; }

.settings-logout-row {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--gl);
}
.btn-logout {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px; font-weight: 600;
  border-radius: var(--radius);
  border: 1.5px solid var(--gl);
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.btn-logout:hover { background: #FEE2E2; color: var(--danger); border-color: #FECACA; }

.btn-sm {
  padding: 7px 12px; background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600; border-radius: 7px;
  white-space: nowrap; transition: background 0.15s;
  flex-shrink: 0;
}
.btn-sm:hover { background: var(--primary-hover); }

.error-msg {
  background: #FEE2E2; color: var(--danger);
  font-size: 13px; font-weight: 500;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}

/* ─── Room pills (multi-select) ──────────────────────────────── */
.room-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}
.room-pill input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.room-pill-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--pill-color, #3B82F6);
  color: var(--pill-color, #3B82F6);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.room-pill input:checked + .room-pill-label {
  background: var(--pill-color, #3B82F6);
  color: #fff;
}
.room-pill-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── Selection banner ───────────────────────────────────────── */
.sel-banner {
  height: 0; overflow: hidden;
  background: #EFF6FF;
  border-bottom: 1px solid #BFDBFE;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--primary);
  flex-shrink: 0;
  transition: height 0.2s ease;
}
.sel-banner.visible { height: 34px; }
.sel-banner button {
  font-size: 14px; color: var(--text-muted);
  padding: 2px 7px; border-radius: 50%;
  transition: background 0.1s;
}
.sel-banner button:hover { background: #BFDBFE; }

/* ─── Chess wrapper ──────────────────────────────────────────── */
.chess-wrapper {
  flex-shrink: 0;
  height: 100dvh;   /* grid fills full screen; scroll down to see feed */
  display: flex;
  overflow: hidden;
}

/* Left panel (labels + corner) — height = content only so separator stops at last room */
.chess-left {
  flex-shrink: 0;
  width: var(--label-w);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gl-strong);
  z-index: 20;
  background: var(--surface);
  align-self: flex-start; /* don't stretch to full screen height */
}

/* Corner: month label only, vertically centered */
.corner {
  flex-shrink: 0;
  height: calc(var(--head-h) + env(safe-area-inset-top));
  background: var(--surface2);
  border-bottom: 1px solid var(--gl-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: env(safe-area-inset-top);
}

.c-month {
  font-size: 11px; font-weight: 900;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  padding: 0 2px;
}

/* Room labels — natural height (no flex:1 so chess-left doesn't stretch past last room) */
.chess-labels {
  overflow: hidden;
}
.room-label {
  height: var(--row-h);
  display: flex;
  align-items: center;
  padding: 0 6px 0 8px;
  font-size: 12px; font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--gl);
  cursor: pointer;
  transition: background 0.12s;
  gap: 6px;
  overflow: hidden;
}
.room-label:hover { background: #F0F7FF; }
/* Keep bottom border on last label — matches chess-body bottom border */
.room-color-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.room-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Scrollable area ────────────────────────────────────────── */
.chess-area {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  min-width: 0;
}

/* ─── Chess header (sticky) ──────────────────────────────────── */
.chess-head {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--surface2);
  padding-top: env(safe-area-inset-top);
}

/* Day number row */
.day-row {
  display: flex;
  height: var(--day-h);
}
.day-head {
  width: var(--day-w);
  flex-shrink: 0;
  height: var(--day-h);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--gl);
  /* Bottom line on every cell — guaranteed to render on each cell */
  border-bottom: 1px solid var(--gl-strong);
  user-select: none;
}
.day-head .day-num {
  font-size: 13px; font-weight: 700; line-height: 1;
}
.day-head .day-dow { font-size: 9px; margin-top: 1px; opacity: 0.75; }
.day-head.today { color: var(--primary); background: var(--today-bg); }
/* Weekends: subtle tint in header only */
.day-head.weekend { background: rgba(251,191,36,0.13); }
.day-head.weekend .day-num { color: #A16207; }
/* month-start: left shadow + keep border-bottom */
.day-head.month-start { box-shadow: inset 2px 0 0 var(--gl-strong); border-bottom: 1px solid var(--gl-strong); }

/* ─── Room tracks ────────────────────────────────────────────── */
.chess-body {
  display: flex;
  flex-direction: column;
  /* Bottom border under last room */
  border-bottom: 1px solid var(--gl-strong);
}

.room-track {
  position: relative;
  height: var(--row-h);
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--gl);
  background: var(--surface);
}
.room-track.alt { background: #FAFBFD; }

/* Day cells */
.day-cell {
  width: var(--day-w);
  flex-shrink: 0;
  height: var(--row-h);
  /* Right border only — never left — so header and body always align */
  border-right: 1px solid var(--gl);
  cursor: pointer;
  transition: background 0.08s;
}
.day-cell:hover { background: #EFF6FF; }
.day-cell.today { background: var(--today-bg); }
/* Weekends: no special background in data rows — grid lines stay clean */
/* Month start: same left shadow technique */
.day-cell.month-start { box-shadow: inset 2px 0 0 var(--gl-strong); }

/* Selection highlight */
.day-cell.sel-start {
  background: rgba(37,99,235,0.15) !important;
  position: relative;
}
.day-cell.sel-start::after {
  content: '';
  position: absolute; inset: 2px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  pointer-events: none;
}

/* ─── Booking bars ───────────────────────────────────────────── */
.booking-bar {
  position: absolute;
  top: 6px;
  height: calc(var(--row-h) - 12px);
  display: flex; align-items: center;
  padding: 0 8px; gap: 5px;
  cursor: pointer;
  overflow: hidden;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: filter 0.12s, transform 0.1s;
}
.booking-bar:hover { filter: brightness(1.08); }
.booking-bar:active { transform: scaleY(0.95); }

.booking-name {
  color: #fff; font-size: 11px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.booking-price {
  color: rgba(255,255,255,0.85); font-size: 10px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0;
}
.booking-guests {
  color: rgba(255,255,255,0.8); font-size: 10px;
  white-space: nowrap; flex-shrink: 0;
}

/* ─── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.92); }

.fab-add {
  right: 18px;
  width: 52px; height: 52px;
  background: var(--primary); color: #fff;
  font-size: 26px; font-weight: 300;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
}
.fab-add:hover { background: var(--primary-hover); }

.fab-settings {
  left: 18px;
  width: 44px; height: 44px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1.5px solid var(--gl);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.fab-settings:hover { background: var(--gl); color: var(--text); }

/* ─── Modals ─────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.3s;
  cursor: pointer;
}
.modal.active .modal-backdrop { background: rgba(0,0,0,0.5); }

.modal-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  max-height: 93dvh;
  overflow-y: auto;
  overflow-x: hidden; /* no horizontal scroll ever */
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overscroll-behavior: contain;
  padding-bottom: env(safe-area-inset-bottom);
  /* Ensure full width */
  width: 100%;
  box-sizing: border-box;
}
.modal.active .modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px; height: 4px; background: var(--gl);
  border-radius: 2px; margin: 12px auto 0;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 1px solid var(--gl);
}
.modal-header h2 { font-size: 18px; font-weight: 700; }

.close-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); color: var(--text-muted); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.close-btn:hover { background: var(--gl); }

.modal-form { padding: 18px 20px 20px; }

.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.form-actions .btn-primary { flex: 1; width: auto; }
.form-actions .btn-danger { flex-shrink: 0; }

/* ─── Guests stepper ─────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--gl);
  border-radius: var(--radius);
  overflow: hidden;
  height: 44px;
  width: fit-content;
}
.stepper-btn {
  width: 44px; height: 44px;
  font-size: 22px; line-height: 1;
  color: var(--text-muted);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.stepper-btn:hover { background: var(--gl); color: var(--text); }
.stepper-btn:active { background: var(--primary); color: #fff; }
.stepper-val {
  min-width: 48px;
  text-align: center;
  font-size: 18px; font-weight: 700;
  color: var(--text);
  border-left: 1px solid var(--gl);
  border-right: 1px solid var(--gl);
  height: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Rate pills ─────────────────────────────────────────────── */
.rate-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.rate-pill { position: relative; cursor: pointer; }
.rate-pill input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.rate-pill-label {
  display: block;
  padding: 9px 16px;
  border: 2px solid var(--gl);
  color: var(--text-muted);
  border-radius: 20px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}
.rate-pill input:checked + .rate-pill-label {
  border-color: var(--primary);
  background: #EFF6FF;
  color: var(--primary);
}

/* ─── Phone row ──────────────────────────────────────────────── */
.phone-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.phone-row input {
  flex: 1;
  min-width: 0;
}
.call-btn {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1.5px solid var(--gl);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.call-btn.active {
  background: #DCFCE7;
  border-color: #86EFAC;
  color: #16A34A;
}
.call-btn:hover { background: var(--gl); }

/* ─── Payment status on bar ──────────────────────────────────── */
.booking-pay {
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.95);
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
  padding: 0 4px;
  line-height: 16px;
}

/* ─── Settings ───────────────────────────────────────────────── */
.section-title {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.room-edit-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.room-name-input {
  flex: 1; padding: 9px 12px;
  border: 1.5px solid var(--gl); border-radius: 8px;
  font-size: 14px; outline: none;
}
.room-name-input:focus { border-color: var(--primary); }

.success-msg { font-size: 13px; color: var(--success); font-weight: 600; padding: 8px 0; }

/* ─── Desktop ────────────────────────────────────────────────── */
@media (min-width: 600px) {
  .modal-sheet {
    bottom: auto; top: 50%; left: 50%; right: auto;
    width: 460px; border-radius: 20px;
    transform: translate(-50%, calc(-50% + 16px));
    max-height: 88dvh;
  }
  .modal.active .modal-sheet { transform: translate(-50%, -50%); }
  .fab { right: 28px; }
  :root { --day-w: 42px; --label-w: 96px; }
}
@media (min-width: 900px) {
  :root { --day-w: 46px; --label-w: 108px; }
}

/* ─── Activity feed ──────────────────────────────────────────── */
.activity-feed {
  flex-shrink: 0;
  padding: 20px 16px calc(90px + env(safe-area-inset-bottom));
  background: var(--surface);
}
.activity-header {
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 2px;
}
.activity-list { display: flex; flex-direction: column; gap: 1px; }
.activity-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.activity-item + .activity-item { margin-top: 1px; }
.act-text {
  font-size: 13px; line-height: 1.45;
  color: var(--text);
}
.act-user { font-weight: 800; }
.act-dates { font-weight: 600; color: var(--text); }
.act-ps-green  { color: #16A34A; font-weight: 700; }
.act-ps-yellow { color: #D97706; font-weight: 700; }
.act-ps-gray   { color: #6B7280; font-weight: 600; }
.act-ps-red    { color: #DC2626; font-weight: 700; }
.act-time {
  font-size: 11px;
  color: var(--text-muted);
}
.activity-empty {
  font-size: 13px; color: var(--text-muted);
  padding: 12px 2px;
  text-align: center;
}
