/* ════════════════════════════════════════════════════════════
   GLOBAL STYLES & LAYOUT SYSTEM — Cozy Cafe Cabin Manager
   ════════════════════════════════════════════════════════════ */

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

:root {
  --sidebar-w: 240px;
  --header-h: 56px;
  --bg: #f8f9fb;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --accent-light: #e0f2fe;
  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --orange: #f59e0b;
  --orange-light: #fef3c7;
  --indigo: #6366f1;
  --indigo-light: #e0e7ff;
  --radius: 12px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── SIDEBAR LAYOUT ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100dvh;
  overflow: hidden;
  transition: width 0.25s, transform 0.25s;
  z-index: 100;
}
.sidebar.collapsed, .sidebar-collapsed .sidebar { width: 56px; }
.sidebar.collapsed .nav-label,
.sidebar-collapsed .sidebar .nav-label,
.sidebar.collapsed .brand-sub,
.sidebar-collapsed .sidebar .brand-sub,
.sidebar.collapsed .brand-name,
.sidebar-collapsed .sidebar .brand-name,
.sidebar.collapsed .workspace-label,
.sidebar-collapsed .sidebar .workspace-label,
.sidebar.collapsed .user-info,
.sidebar-collapsed .sidebar .user-info { display: none; }
.sidebar.collapsed .nav-item,
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .brand,
.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 12px 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg { color: #fff; width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-secondary); }

.workspace-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 16px 16px 6px;
}

nav { flex: 1; padding: 4px 8px; overflow-y: auto; min-height: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 4px;
  background: var(--bg); border-radius: 8px;
}
.user-info .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid var(--accent-light);
  flex-shrink: 0;
}
.user-info .user-name { font-size: 13px; font-weight: 600; }
.user-info .user-role { font-size: 11px; color: var(--text-secondary); }

/* ── MAIN AREA ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.toggle-btn {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px;
  color: var(--text-secondary);
  display: flex; align-items: center;
  flex-shrink: 0;
}
.toggle-btn:hover { background: var(--bg); }

.search-box {
  flex: 1; max-width: 400px;
  position: relative;
}
.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px 7px 36px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: var(--text-primary);
}
.search-box input:focus { border-color: var(--accent); background: #fff; }
.search-box .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 15px; height: 15px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.notif-btn {
  position: relative; background: none; border: none;
  cursor: pointer; padding: 6px; border-radius: 6px;
  color: var(--text-secondary);
  display: flex; align-items: center;
}
.notif-btn:hover { background: var(--bg); }
.notif-badge {
  position: absolute; top: 3px; right: 3px;
  width: 8px; height: 8px; background: var(--red);
  border-radius: 50%; border: 2px solid #fff;
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 4px 8px;
  border-radius: 8px;
}
.user-pill:hover { background: var(--bg); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border: 2px solid var(--accent-light);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-secondary); }

/* ── CONTENT ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title { font-size: 26px; font-weight: 700; color: #0f172a; }
.page-sub { font-size: 14px; color: var(--text-secondary); margin-top: 3px; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  transition: all 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.stat-details {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  line-height: 1.2;
}
.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 18px;
  height: 18px;
}
.icon-blue { background: var(--accent-light); color: var(--accent); }
.icon-red  { background: var(--red-light);   color: var(--red); }
.icon-green{ background: var(--green-light);  color: var(--green); }
.icon-gray { background: #f3f4f6; color: var(--text-secondary); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 3px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  margin-top: 4px;
}

/* ── CARDS ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}
.card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.5;
}

/* ── GENERAL BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--green-light); color: #15803d; }
.badge-orange { background: var(--orange-light); color: #b45309; }
.badge-red { background: var(--red-light); color: var(--red); }

/* Global Stats Responsive Queries */
@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 560px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  .stat-card {
    padding: 14px 16px !important;
    gap: 12px !important;
  }
}

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  display: block;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
}
.form-select {
  cursor: pointer;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input-prefix {
  position: relative;
}
.input-prefix .prefix-symbol {
  position: absolute;
  left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  pointer-events: none;
}
.input-prefix .form-input {
  padding-left: 26px;
}

/* ── UTILITY BUTTONS ── */
.btn-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { opacity: .88; }

.btn-outline {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(14,165,233,.3);
}

.btn-full {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
  font-family: inherit;
  margin-top: 8px;
}
.btn-full:hover { background: var(--accent-dark); }

/* ── MODALS ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(1px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.btn-cancel {
  flex: 1; background: #fff; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 10px;
  font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
}
.btn-confirm {
  flex: 1; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-confirm:hover { background: var(--accent-dark); }
.btn-danger {
  flex: 1; background: var(--red); color: #fff; border: none;
  border-radius: 8px; padding: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-danger:hover { background: #dc2626; }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── RESPONSIVE TABLES WITH SCROLLBAR SLIDER ── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Enforce column structure and prevent cell squishing on mobile views */
.bookings-table {
  min-width: 900px !important;
}
.cabins-table {
  min-width: 600px !important;
}
.pricing-table {
  min-width: 600px !important;
}
.user-table {
  min-width: 480px !important;
}
.report-table {
  min-width: 800px !important;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w) !important;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  .sidebar.mobile-open, .sidebar.open { transform: translateX(0); }
  .main { width: 100%; }
  .topbar { padding: 0 14px; gap: 10px; }
  .search-box { max-width: 260px; }
  .user-pill .user-name, .user-pill .user-role { display: none; }
  .content { padding: 18px 16px 36px; }
  
  /* Stack double-column grid forms vertically on mobile/tablet screens */
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Make notification dropdown responsive to screen edge */
  .notif-dropdown {
    width: 290px !important;
    right: -60px !important;
  }

  /* Page header stacks nicely */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header .btn-group {
    width: 100%;
  }
  .page-header .btn-group .btn {
    flex: 1;
    justify-content: center;
  }

  /* Sidebar footer logout always visible on mobile */
  .sidebar-footer .nav-item .nav-label { display: inline !important; }
}

/* ── ULTIMATE MOBILE & VIEWPORT FLUIDITY (UNDER 480PX) ── */
@media (max-width: 480px) {
  /* Fluid content spacing for maximum layout width */
  .content {
    padding: 12px 10px 24px !important;
  }
  
  /* Fluid page headers to prevent text wrapping */
  .page-title {
    font-size: 20px !important;
  }
  .page-sub {
    font-size: 11.5px !important;
    margin-top: 1px !important;
  }
  
  /* Compact cards padding to optimize screen real estate */
  .card {
    padding: 16px 12px !important;
    border-radius: 8px !important;
  }
  
  /* Stack modal buttons vertically for clear action touch targets */
  .modal {
    padding: 20px 14px !important;
    border-radius: 12px !important;
  }
  .modal-title {
    font-size: 15.5px !important;
  }
  .modal-actions {
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 18px !important;
  }
  .btn-cancel, .btn-confirm, .btn-danger {
    width: 100% !important;
    margin: 0 !important;
    padding: 10px !important;
    font-size: 13px !important;
  }
  
  /* Fluid topbar search inputs */
  .search-box {
    max-width: 140px !important;
  }
  .search-box input {
    font-size: 12px !important;
    padding: 6px 10px 6px 30px !important;
  }
  .search-box .search-icon {
    left: 8px !important;
    width: 12px !important;
    height: 12px !important;
  }

  /* Notification dropdown full-width on very small screens */
  .notif-dropdown {
    width: calc(100vw - 32px) !important;
    right: -10px !important;
    max-height: 300px !important;
  }

  /* Button group stacks vertically */
  .btn-group {
    flex-direction: column;
  }
  .btn-group .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── QTY ADJUSTMENT CONTROLS ── */
.qty-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
  outline: none;
}
.qty-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.qty-val {
  display: inline-block;
  width: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

