/* ============================================================
   HelloStay Backoffice — Design System (Dark / Light Theme)
   ============================================================ */

:root {
  --primary: #10b981;
  --primary-light: #34d399;
  --primary-dark: #059669;
  --accent: #C8A96E;
  --accent-light: #d4bc8a;
  --bg: #0a0a0b;
  --bg-secondary: #111114;
  --bg-tertiary: #1a1a1f;
  --surface: #16161a;
  --surface-hover: #1a1a1f;
  --text: #f5f5f7;
  --text-secondary: #a1a1aa;
  --text-muted: #8a8a96;
  --border: #35353f;
  --border-light: #2a2a32;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', monospace;
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: 0.2s ease;

  /* Chat message bubbles */
  --msg-guest: #0d3d36;
  --msg-bot: #262626;
  --msg-staff: #1e1a4a;
  --msg-unknown: #374151;
  --msg-text: #ffffff;
  --msg-text-muted: rgba(255,255,255,0.5);
  --msg-text-secondary: rgba(255,255,255,0.75);

  /* Chart colors (readable via getComputedStyle) */
  --chart-grid: #2a2a32;
  --chart-tick: #a1a1aa;

  /* Toggle track */
  --toggle-off: #3a3a45;

  /* Sidebar text */
  --sidebar-text: rgba(255,255,255,0.6);
  --sidebar-text-hover: rgba(255,255,255,0.9);
  --sidebar-text-muted: rgba(255,255,255,0.35);
  --sidebar-hover-bg: rgba(255,255,255,0.06);

  color-scheme: dark;
}

/* ── Light Theme (WhatsApp-inspired) ── */
[data-theme="light"] {
  --primary: #00a884;
  --primary-light: #00c49a;
  --primary-dark: #008f6f;
  --accent: #b8963e;
  --accent-light: #c9a856;

  --bg: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f2f5;
  --surface: #ffffff;
  --surface-hover: #f5f5f5;

  --text: #111b21;
  --text-secondary: #3b4a54;
  --text-muted: #667781;

  --border: #d1d7db;
  --border-light: #dfe5e7;

  --success: #00a884;
  --warning: #e37400;
  --danger: #ea0038;
  --info: #0077e6;

  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --msg-guest: #d9fdd3;
  --msg-bot: #ffffff;
  --msg-staff: #e8e0f5;
  --msg-unknown: #f0f2f5;
  --msg-text: #111b21;
  --msg-text-muted: rgba(0,0,0,0.45);
  --msg-text-secondary: rgba(0,0,0,0.65);

  --chart-grid: #d1d7db;
  --chart-tick: #667781;

  --toggle-off: #c5c5c5;

  --sidebar-text: #3b4a54;
  --sidebar-text-hover: #111b21;
  --sidebar-text-muted: #667781;
  --sidebar-hover-bg: rgba(0,0,0,0.04);

  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }

/* ── Typography ── */
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  color: var(--text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width var(--transition);
}
.sidebar-brand {
  padding: 20px 24px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px;
}
.sidebar-section {
  margin-bottom: 8px;
}
.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--sidebar-text-muted);
  padding: 12px 12px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}
.sidebar-link.active {
  background: rgba(16,185,129,0.12);
  color: var(--primary);
}
.sidebar-link svg, .sidebar-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-link.active svg, .sidebar-link.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.sidebar-user:hover { background: var(--sidebar-hover-bg); }
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text-muted); }

/* ── Sidebar collapse toggle ── */
.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 16px;
  border-radius: 4px;
  transition: all var(--transition);
  margin-left: auto;
}
.sidebar-collapse-btn:hover { color: var(--sidebar-text-hover); background: var(--sidebar-hover-bg); }

.sidebar-link .sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0.7;
}
.sidebar-link.active .sidebar-icon { opacity: 1; }
.sidebar-link .sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar collapsed state */
.app-layout.sidebar-collapsed .sidebar { width: 60px; }
.app-layout.sidebar-collapsed .sidebar-brand span { display: none; }
.app-layout.sidebar-collapsed .sidebar-brand { padding: 16px 12px; justify-content: center; }
.app-layout.sidebar-collapsed .sidebar-section-title { display: none; }
.app-layout.sidebar-collapsed .sidebar-link { justify-content: center; padding: 12px 0; gap: 0; }
.app-layout.sidebar-collapsed .sidebar-label { display: none; }
.app-layout.sidebar-collapsed .sidebar-user-info { display: none; }
.app-layout.sidebar-collapsed .sidebar-user { justify-content: center; padding: 8px 4px; }
.app-layout.sidebar-collapsed .sidebar-footer { padding: 12px 6px; }
.app-layout.sidebar-collapsed .sidebar-nav { padding: 8px 6px; }
.app-layout.sidebar-collapsed .sidebar-collapse-btn { margin: 0 auto; }

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

/* ── Header ── */
.header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.header-title { font-size: 18px; font-weight: 600; flex: 1; color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* Theme toggle */
.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.theme-toggle-btn:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
  color: var(--primary);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Page content ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--text); }

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.stat-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-card-change {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-light); }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 8px; }

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-secondary);
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.form-select {
  color-scheme: inherit;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-secondary);
}
tr:hover { background: var(--surface-hover); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-neutral { background: var(--surface-hover); color: var(--text-secondary); }

/* ── Toggle Switch ── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.toggle-switch input { display: none; }
.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--toggle-off);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

/* ── Tabs (segmented control) ── */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.tab:hover {
  color: var(--text-secondary);
  background: var(--surface-hover);
}
.tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 18px; color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s, fadeOut 0.3s 2.7s;
  max-width: 400px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  flex-direction: column;
  gap: 16px;
}

/* ── Auth pages ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}
.auth-brand h1 {
  font-size: 28px;
  color: var(--primary);
  font-weight: 700;
}
.auth-brand p { color: var(--text-muted); margin-top: 4px; }
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Charts ── */
.chart-container {
  position: relative;
  height: 280px;
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* ── Beta banner ── */
.beta-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 16px 24px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.beta-banner-icon { font-size: 24px; }
.beta-banner h4 { font-weight: 600; }
.beta-banner p { font-size: 13px; opacity: 0.85; margin-top: 2px; }

/* ── Responsive ── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s;
  }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utilities ── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
