/* X Stay - Lịch Đặt Phòng */
:root {
  --primary: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-dark: #1e3a8a;
  --surface: #ffffff;
  --bg: #f0f9ff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --available: #ffffff;
  --booked: #fca5a5;
  --booked-border: #ef4444;
  --hourly: #fcd34d;
  --hourly-border: #f59e0b;
  --locked: #e2e8f0;
  --locked-border: #94a3b8;
  --holiday: #bfdbfe;
  --holiday-border: #3b82f6;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ── */
.site-header {
  background: var(--primary-dark);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.site-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.site-logo span { color: #60a5fa; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hotline-btn {
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.admin-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
}
.admin-link:hover { background: rgba(255,255,255,0.1); }

/* ── Month Nav ── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.month-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.month-btn:hover { background: var(--primary); color: white; }

.month-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  min-width: 160px;
  text-align: center;
}

/* ── Location Tabs ── */
.location-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.location-tabs::-webkit-scrollbar { height: 3px; }

.loc-tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.loc-tab:hover { border-color: var(--primary); color: var(--primary); }
.loc-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Legend ── */
.legend {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid;
}
.legend-dot.available { background: white; border-color: var(--border); }
.legend-dot.booked { background: var(--booked); border-color: var(--booked-border); }
.legend-dot.hourly { background: var(--hourly); border-color: var(--hourly-border); }
.legend-dot.locked { background: var(--locked); border-color: var(--locked-border); }
.legend-dot.holiday { background: var(--holiday); border-color: var(--holiday-border); }

/* ── Calendar ── */
.calendar-outer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  border-radius: var(--radius);
}
.calendar-outer::-webkit-scrollbar { height: 6px; }
.calendar-outer::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

.cal-table {
  border-collapse: collapse;
  min-width: max-content;
  width: 100%;
  background: white;
  box-shadow: var(--shadow);
}

/* Sticky room name column */
.room-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: white;
  min-width: 145px;
  max-width: 145px;
}

/* Date header */
.date-th {
  min-width: 42px;
  width: 42px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 2px;
  border: 1px solid var(--border);
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 2;
}
.date-th .day-num { font-size: 13px; line-height: 1.2; }
.date-th .day-name { font-size: 9px; color: var(--text-muted); }
.date-th.is-saturday { background: #fef3c7; }
.date-th.is-sunday { background: #fee2e2; }
.date-th.is-today { background: var(--primary-light); color: var(--primary); }

/* Room header cell */
.room-header-th {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  background: #f8fafc;
  min-width: 145px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Location group row */
.loc-row td {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  letter-spacing: 0.3px;
}
.loc-row .room-col {
  position: sticky;
  left: 0;
  z-index: 3;
}

/* Room name cell */
.room-name-td {
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--border);
  border-right: 2px solid #e2e8f0;
}
.room-name-td .rn-main {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.room-name-td .rn-note {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
}
.room-name-td .room-links {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.room-links a {
  font-size: 9px;
  color: var(--primary);
  text-decoration: none;
  padding: 1px 4px;
  background: var(--primary-light);
  border-radius: 3px;
}
.room-links a:hover { background: var(--primary); color: white; }
.room-links a.hidden { display: none; }

/* Booking cell */
.cell {
  min-width: 42px;
  width: 42px;
  height: 38px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  font-size: 9px;
  line-height: 1.2;
  padding: 2px;
  transition: filter 0.1s;
  user-select: none;
}
.cell:hover { filter: brightness(0.88); }
.cell.available { background: var(--available); }
.cell.booked { background: var(--booked); color: #7f1d1d; font-weight: 600; }
.cell.hourly { background: var(--hourly); color: #78350f; font-weight: 600; }
.cell.locked { background: var(--locked); color: #475569; }
.cell.holiday { background: var(--holiday); }
.cell.selected { outline: 2px solid var(--primary); outline-offset: -2px; z-index: 1; }
.cell.in-range { background: #dbeafe !important; }

/* Weekend styling */
.cell.is-saturday { border-top-color: #f59e0b; }
.cell.is-sunday { border-top-color: #ef4444; }

/* ── Price Panel ── */
#price-panel {
  position: fixed;
  right: -420px;
  top: 0;
  bottom: 0;
  width: 400px;
  background: white;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 200;
  overflow-y: auto;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}
#price-panel.open { right: 0; }

.panel-header {
  background: var(--primary-dark);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h3 { font-size: 15px; font-weight: 700; }
.panel-close {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.panel-close:hover { opacity: 0.7; }

.panel-body { padding: 14px; flex: 1; }

.panel-location {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.panel-room-links {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-room-links a {
  flex: 1;
  text-align: center;
  padding: 7px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid;
}
.btn-img { color: #7c3aed; border-color: #7c3aed; background: #f5f3ff; }
.btn-img:hover { background: #7c3aed; color: white; }
.btn-vid { color: #dc2626; border-color: #dc2626; background: #fef2f2; }
.btn-vid:hover { background: #dc2626; color: white; }
.btn-hidden { display: none !important; }

.price-table-mini {
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 14px;
  font-size: 12px;
}
.price-table-mini h4 {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.price-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.price-row:last-child { border-bottom: none; }
.price-row .day-group { color: var(--text-muted); }
.price-row .price-vals { font-weight: 600; color: var(--primary-dark); font-size: 11px; text-align: right; }

/* Calculator section */
.calc-section {
  background: #f0f9ff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}
.calc-section h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.form-row.single { grid-template-columns: 1fr; }

.form-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 7px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  background: white;
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Price breakdown */
.breakdown-box {
  background: white;
  border-radius: 6px;
  border: 1.5px solid var(--primary-light);
  margin-top: 10px;
  overflow: hidden;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 11px;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row .bd-date { color: var(--text-muted); }
.breakdown-row .bd-price { font-weight: 600; color: var(--primary-dark); }
.breakdown-row .bd-commission { font-size: 10px; color: #16a34a; }
.breakdown-total {
  background: var(--primary);
  color: white;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
}
.breakdown-total .total-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.breakdown-total .total-item { font-size: 11px; }
.breakdown-total .total-big {
  grid-column: 1/-1;
  font-size: 16px;
  font-weight: 800;
  margin-top: 4px;
}
.breakdown-total .t-label { opacity: 0.8; font-weight: 400; }
.breakdown-total .t-green { color: #86efac; }
.breakdown-total .t-yellow { color: #fde68a; }

/* Zalo button */
.zalo-btn {
  width: 100%;
  padding: 13px;
  background: #0068ff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  transition: background 0.15s;
}
.zalo-btn:hover { background: #0051cc; }
.zalo-btn:disabled { background: #94a3b8; cursor: not-allowed; }
.zalo-icon { font-size: 20px; }

.bank-info {
  margin-top: 10px;
  padding: 8px;
  background: #f0fdf4;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  font-size: 11px;
  color: #166534;
  text-align: center;
}

/* ── Overlay backdrop ── */
#panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}
#panel-backdrop.show { display: block; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 500;
  transition: transform 0.3s ease;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── Info bar ── */
.info-bar {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  padding: 6px 16px;
  font-size: 11px;
  color: #92400e;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.info-bar span { display: flex; align-items: center; gap: 4px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #price-panel {
    width: 100%;
    right: -100%;
    top: auto;
    bottom: 0;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    transition: right 0.3s ease, bottom 0.3s ease;
  }
  #price-panel.open { right: 0; bottom: 0; }

  .site-logo { font-size: 16px; }
  .month-label { font-size: 15px; min-width: 130px; }
  .room-col { min-width: 120px; max-width: 120px; }
  .cell { min-width: 36px; width: 36px; height: 34px; }
  .date-th { min-width: 36px; width: 36px; }
}

/* ── Admin specific ── */
.admin-bar {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cell.admin-mode { cursor: pointer; }
.cell.admin-mode:hover::after {
  content: '✏️';
  font-size: 10px;
}

/* Admin login modal */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: white;
  border-radius: 12px;
  padding: 32px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 6px;
}
.login-box p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-input:focus { outline: none; border-color: var(--primary); }
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.login-btn:hover { background: var(--primary-dark); }
.login-error {
  color: #dc2626;
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* Admin cell modal */
.cell-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cell-modal {
  background: white;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.cell-modal h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.cell-modal .cell-modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.status-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.status-btn {
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  background: white;
  transition: all 0.1s;
}
.status-btn:hover, .status-btn.active { border-color: currentColor; }
.status-btn.s-available { color: #16a34a; }
.status-btn.s-available.active { background: #dcfce7; }
.status-btn.s-booked { color: #dc2626; }
.status-btn.s-booked.active { background: var(--booked); }
.status-btn.s-hourly { color: #d97706; }
.status-btn.s-hourly.active { background: var(--hourly); }
.status-btn.s-locked { color: #475569; }
.status-btn.s-locked.active { background: var(--locked); }

.note-input {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.note-input:focus { outline: none; border-color: var(--primary); }

.modal-actions {
  display: flex;
  gap: 8px;
}
.btn-save {
  flex: 1;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel {
  padding: 10px 16px;
  background: #f1f5f9;
  color: var(--text-muted);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* Admin room settings */
.room-settings-section {
  padding: 16px;
}
.room-settings-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--primary-dark);
}
.room-setting-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.room-setting-card h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.url-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}
.url-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 35px;
}
.url-input {
  flex: 1;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
}
.url-input:focus { outline: none; border-color: var(--primary); }
.url-save-btn {
  padding: 5px 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}

/* Loading spinner */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  gap: 10px;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin tabs */
.admin-tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
}
.admin-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }
