/* ===== CSS Variables ===== */
:root {
  --primary: #1a3c5e;
  --primary-light: #2563a8;
  --primary-dark: #0f2540;
  --accent: #d4a843;
  --accent-light: #f0c060;
  --sidebar-width: 260px;
  --topbar-height: 65px;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --border: #dde3ed;
  --text: #1e2d3d;
  --text-muted: #6b7c93;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --grey: #94a3b8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 15px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Dashboard Layout ===== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  z-index: 10;
  box-shadow: 3px 0 15px rgba(0,0,0,0.2);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-logo .logo-text { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 11px; color: rgba(255,255,255,0.55); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 14px; font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: var(--accent); color: var(--primary-dark); font-weight: 600; }
.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  margin-bottom: 8px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-dark); font-weight: 700; font-size: 14px;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
.btn-logout {
  width: 100%; padding: 9px; border-radius: 8px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); font-size: 13px;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-logout:hover { background: rgba(239,68,68,0.2); border-color: var(--danger); color: #fff; }

/* ===== Main Content ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: var(--surface);
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.topbar-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 13px; color: var(--text-muted); }

.content-area { flex: 1; overflow-y: auto; padding: 28px; }

/* ===== Sections ===== */
.section { display: none; }
.section.active { display: block; }

/* ===== Stat Cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-light);
  transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.green { border-left-color: var(--success); }
.stat-card.amber { border-left-color: var(--warning); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.grey { border-left-color: var(--grey); }
.stat-card.gold { border-left-color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Tables ===== */
.table-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-title { font-size: 15px; font-weight: 600; color: var(--primary); }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg); padding: 11px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; }
tr:hover td { background: #f8fafc; }

/* ===== Status Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-available { background: #dcfce7; color: #166534; }
.badge-reserved { background: #fef9c3; color: #854d0e; }
.badge-occupied { background: #fee2e2; color: #991b1b; }
.badge-maintenance { background: #f1f5f9; color: #475569; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-served { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #f1f5f9; color: #475569; }
.badge-checked_in { background: #dbeafe; color: #1e40af; }
.badge-checked_out { background: #f1f5f9; color: #475569; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: none; transition: var(--transition); cursor: pointer;
}
.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-accent:hover { background: var(--accent-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(-10px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,168,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Context Menu ===== */
.context-menu {
  position: fixed; z-index: 2000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  overflow: hidden;
  animation: contextIn 0.12s ease;
  display: none;
}
.context-menu.open { display: block; }
@keyframes contextIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.context-menu-header {
  padding: 10px 14px 8px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.context-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  font-size: 14px; color: var(--text);
  cursor: pointer; transition: background var(--transition);
  border: none; background: none; width: 100%; text-align: left;
}
.context-item:hover { background: var(--bg); }
.context-item .ci-icon { font-size: 16px; width: 20px; text-align: center; }
.context-item.ci-danger { color: var(--danger); }
.context-item.ci-danger:hover { background: #fee2e2; }
.context-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== Alerts / Toasts ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--success); }
.toast-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.toast-info { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--primary-light); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey); }

/* ===== Billing / Invoice ===== */
.bill-container {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}
.bill-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 24px 28px 20px;
  text-align: center;
}
.bill-hotel-name {
  font-size: 22px; font-weight: 800; letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.bill-hotel-sub {
  font-size: 12px; opacity: 0.75; letter-spacing: 0.06em; text-transform: uppercase;
}
.bill-type-badge {
  display: inline-block;
  background: var(--accent); color: var(--primary-dark);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 14px; border-radius: 20px; margin-top: 10px;
}
.bill-info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; border-bottom: 1px solid var(--border);
}
.bill-info-cell {
  padding: 14px 20px;
  border-right: 1px solid var(--border);
  font-size: 13px;
}
.bill-info-cell:nth-child(even) { border-right: none; }
.bill-info-cell:nth-child(n+3) { border-top: 1px solid var(--border); }
.bill-info-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px;
}
.bill-info-value { font-size: 14px; font-weight: 600; color: var(--text); }

.bill-items-section { padding: 20px 24px; }
.bill-items-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px;
}
.bill-items-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.bill-items-table th {
  text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
  padding: 6px 8px; border-bottom: 2px solid var(--border);
  background: none;
}
.bill-items-table td {
  padding: 9px 8px; border-top: 1px solid var(--border); border-bottom: none;
  font-size: 13px;
}
.bill-items-table tr:hover td { background: #f8fafc; }
.bill-items-table td:last-child,
.bill-items-table th:last-child { text-align: right; }
.bill-items-table td:nth-child(2),
.bill-items-table th:nth-child(2) { text-align: center; }

.bill-totals { padding: 0 24px 20px; }
.bill-subtotal-row {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
  padding: 5px 0;
}
.bill-subtotal-row.discount { color: var(--success); }
.bill-divider { height: 1px; background: var(--border); margin: 10px 0; }
.bill-grand-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: 10px; color: #fff;
  font-size: 16px; font-weight: 800;
  margin-top: 6px;
}
.bill-grand-total .amount { font-size: 20px; color: var(--accent-light); }

.bill-payment-section {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}
.bill-payment-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px;
}
.payment-methods {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.payment-method-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text-muted);
  transition: all var(--transition);
}
.payment-method-btn .pm-icon { font-size: 20px; }
.payment-method-btn:hover { border-color: var(--primary-light); color: var(--primary-light); background: #dbeafe; }
.payment-method-btn.selected { border-color: var(--primary-light); background: #dbeafe; color: var(--primary); }

.bill-footer {
  text-align: center; padding: 14px 24px 20px;
  font-size: 11px; color: var(--text-muted);
  border-top: 1px dashed var(--border);
}
.bill-footer strong { color: var(--primary); }

.bill-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 16px 24px; border-top: 1px solid var(--border);
  background: var(--bg);
}
.bill-actions .btn { flex: 1; min-width: 120px; justify-content: center; }

/* Print styles */
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .bill-actions, .modal-footer, .menu-toggle, .sidebar,
  .topbar, .toast-container { display: none !important; }
  .modal-overlay { position: static; background: none; }
  .modal { box-shadow: none; max-height: none; }
  .bill-grand-total { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bill-header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ===== Sidebar overlay backdrop (mobile) ===== */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

/* ===== Hamburger / Menu toggle ===== */
.menu-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: none; background: var(--bg);
  border-radius: 8px; cursor: pointer;
  color: var(--primary); font-size: 20px;
  transition: background var(--transition);
  flex-shrink: 0;
}
.menu-toggle:hover { background: var(--border); }

/* ===== Responsive ===== */

/* Large screens: 1024px+ — full sidebar */
@media (min-width: 1025px) {
  .sidebar { transform: translateX(0) !important; }
}

/* Medium: 769px – 1024px — icon-only sidebar */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar { width: 70px; }
  .nav-label, .logo-text, .logo-sub, .user-name, .user-role,
  .btn-logout span { display: none; }
  .sidebar-logo { justify-content: center; }
  .sidebar-logo .logo-icon { margin: 0 auto; }
  .nav-item { justify-content: center; padding: 13px; }
  .nav-item .nav-icon { font-size: 20px; }
  .user-info { justify-content: center; }
  .user-avatar { margin: 0 auto; }
  .btn-logout { padding: 9px; font-size: 18px; }
  .sidebar-footer { padding: 12px 8px; }
  .sidebar-header { padding: 18px 8px; }
}

/* Small / Mobile: ≤ 768px — hidden sidebar, overlay on open */
@media (max-width: 768px) {
  .app-layout { position: relative; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.open { transform: translateX(0); }

  .menu-toggle { display: flex; }

  .main-content { width: 100%; min-width: 0; }

  .topbar {
    padding: 12px 16px;
    gap: 10px;
  }
  .topbar-title { font-size: 17px; }
  .topbar-subtitle { font-size: 12px; }
  .topbar-date { display: none; }

  .content-area { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }

  .modal {
    max-width: calc(100vw - 24px);
    margin: 12px;
    max-height: 92dvh;
  }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 22px; }
}

/* Extra small: ≤ 400px */
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-right { display: none; }
  .content-area { padding: 12px; }
  .modal { margin: 8px; max-height: 95dvh; }
}
