/*
 * THE LOXLEY — ADMIN DESIGN SYSTEM
 * Modern Studio — zinc neutrals, indigo accent
 */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
:root {
  --ink:        #09090b;
  --ink-2:      #27272a;
  --ink-3:      #3f3f46;
  --paper:      #fafafa;
  --paper-2:    #f4f4f5;
  --paper-3:    #ffffff;
  --paper-4:    #f4f4f5;
  --accent:     #6366f1;
  --accent-2:   #4f46e5;
  --line:       #e4e4e7;
  --line-soft:  #f4f4f5;
  --muted:      #71717a;
  --muted-2:    #a1a1aa;
  --rose:       #ef4444;
  --moss:       #22c55e;
  --indigo:     #6366f1;

  --font-display: 'Geist', 'Inter', -apple-system, system-ui, sans-serif;
  --font-body:    'Geist', 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono:    'Geist', 'Inter', -apple-system, system-ui, sans-serif;
}

/* ── Dark Mode ── */
html.dark {
  --ink:        #ffffff;
  --ink-2:      #e4e4e7;
  --ink-3:      #d4d4d8;
  --paper:      #09090b;
  --paper-2:    #18181b;
  --paper-3:    #27272a;
  --paper-4:    #27272a;
  --accent:     #6366f1;
  --accent-2:   #a5b4fc;
  --line:       #27272a;
  --line-soft:  #18181b;
  --muted:      #a1a1aa;
  --muted-2:    #71717a;
  --rose:       #f87171;
  --moss:       #4ade80;
  --indigo:     #a5b4fc;
}

/* ── Theme Toggle — Sun / Moon Pill ── */
.h-theme-toggle {
  appearance: none; border: 0; background: transparent;
  padding: 0; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center;
}
.h-toggle-track {
  position: relative;
  width: 48px; height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  transition: background .35s, border-color .35s;
}
html.dark .h-toggle-track {
  background: rgba(250,250,250,0.08);
  border-color: rgba(250,250,250,0.2);
}
.h-toggle-thumb {
  position: absolute;
  left: 2px; top: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .4s cubic-bezier(.4,0,.2,1), background .35s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,0.15);
  z-index: 2;
}
html.dark .h-toggle-thumb {
  transform: translateX(22px);
}
.h-icon-sun, .h-icon-moon {
  font-size: 11px; line-height: 1;
  position: absolute;
  transition: opacity .25s;
  color: var(--paper);
  pointer-events: none;
  user-select: none;
}
.h-icon-sun  { opacity: 1; }
html.dark .h-icon-sun  { opacity: 0; }
.h-icon-moon { opacity: 0; }
html.dark .h-icon-moon { opacity: 1; }
.h-theme-toggle:hover .h-toggle-track { border-color: var(--accent); }
.h-theme-toggle:focus-visible .h-toggle-track {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Override Tailwind dark-mode styles on admin pages */
html.admin-page,
html.admin-page body {
  background: var(--paper) !important;
  color: var(--ink) !important;
}

html.admin-page body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Film grain overlay */
html.admin-page body::before {
  display: none !important;
}
html.dark.admin-page body::before {
  display: none !important;
}

/* ── Typography ────────────────────────────────────────────────────────────── */
.admin-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink);
}
.admin-display em { font-style: normal; color: var(--ink-2); }

.admin-mono {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  background: var(--paper);
}

.admin-content {
  padding: 40px 48px;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .admin-content { padding: 28px 24px; }
}

@media (max-width: 640px) {
  .admin-content { padding: 20px 16px; }
}

/* ── Mobile Top Bar ────────────────────────────────────────────────────────── */
.admin-topbar {
  display: none;
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 14px 20px;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

@media (max-width: 900px) {
  .admin-topbar { display: flex; }
}

.admin-topbar-brand {
  font-family: var(--font-display);
  font-style: normal;
  font-size: 20px;
  font-weight: 600;
  color: var(--paper);
  letter-spacing: -0.02em;
}

.admin-topbar-menu {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(250,250,250,0.7);
  font-size: 18px;
  padding: 4px;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.admin-page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.05;
  margin: 0 0 4px 0;
}

.admin-page-sub {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
}

.admin-page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Panels / Cards ────────────────────────────────────────────────────────── */
.panel {
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 28px;
}

.panel-sm { padding: 20px; }
.panel-lg { padding: 36px; }

.panel-accent {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 24px 28px;
}

.panel-ink {
  background: var(--ink);
  border: 1px solid var(--ink-2);
  padding: 28px;
  color: var(--paper);
}

/* ── KPI Stat Cards ────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 24px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-decoration: none;
  display: block;
  color: var(--ink);
}

.stat-card:hover {
  background: var(--paper-4);
  border-color: rgba(0,0,0,0.28);
  transform: translateY(-1px);
}

html.dark .stat-card:hover {
  border-color: rgba(181, 133, 67, 0.3);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 13px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-note {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-note .pip { margin-right: 0; }

/* Occupancy bar */
.occ-bar-track {
  width: 100%;
  height: 2px;
  background: var(--line);
  margin-top: 12px;
}
.occ-bar-fill {
  height: 2px;
  background: var(--accent);
  transition: width 0.6s ease;
}

/* ── Business Profile Card ─────────────────────────────────────────────────── */
.profile-card {
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-style: normal;
  color: var(--ink);
  flex-shrink: 0;
  overflow: hidden;
}

.profile-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.profile-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--moss);
}

.profile-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
  text-decoration: none;
}
.profile-edit:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* ── Share / Booking Link ──────────────────────────────────────────────────── */
.share-card {
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin-bottom: 36px;
}

.share-url {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.10em;
  color: var(--muted);
  margin-top: 4px;
}

.share-icon-wrap {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn-accent {
  background: var(--accent);
  color: var(--paper);
  border: 1px solid var(--accent);
}
.btn-accent:hover { background: var(--accent-2); border-color: var(--accent-2); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

.btn-soft {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-soft:hover { background: var(--paper-4); border-color: rgba(0,0,0,0.22); }

.btn-moss {
  background: rgba(90,122,79,0.12);
  color: var(--moss);
  border: 1px solid rgba(90,122,79,0.3);
}
.btn-moss:hover { background: rgba(90,122,79,0.2); }

.btn-sm { padding: 7px 14px; font-size: 9.5px; }
.btn-lg { padding: 14px 28px; font-size: 11px; }

/* ── Status Indicators ─────────────────────────────────────────────────────── */
.pip {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}
.pip-live  { background: var(--moss); box-shadow: 0 0 0 3px rgba(90,122,79,0.18); }
.pip-warn  { background: var(--accent); }
.pip-rose  { background: var(--rose); }
.pip-muted { background: var(--muted-2); }

/* ── Section Eyebrow ───────────────────────────────────────────────────────── */
.section-eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.section-eyebrow .eyebrow-rule {
  flex: 1;
  height: 0.5px;
  background: var(--line);
}
.section-eyebrow .eyebrow-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Stats Grid ────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  margin-bottom: 28px;
}

.stats-grid .stat-card {
  border: none;
  border-right: 0.5px solid var(--line);
}
.stats-grid .stat-card:last-child { border-right: none; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid .stat-card:nth-child(2) { border-right: none; }
  .stats-grid .stat-card:nth-child(1),
  .stats-grid .stat-card:nth-child(2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid .stat-card { border-right: none; border-bottom: 1px solid var(--line); }
  .stats-grid .stat-card:last-child { border-bottom: none; }
}

/* ── Chart Section ─────────────────────────────────────────────────────────── */
.chart-panel {
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 28px;
  margin-bottom: 28px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── AI Panel ──────────────────────────────────────────────────────────────── */
.ai-panel {
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 28px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.ai-panel-blur {
  filter: blur(4px);
  opacity: 0.3;
  pointer-events: none;
  user-select: none;
  transition: all 0.5s;
}

.ai-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250,250,250,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  z-index: 10;
}

html.dark .ai-lock-overlay {
  background: rgba(12, 26, 20, 0.88);
}

.ai-lock-icon {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 22px;
  color: var(--accent);
}

/* ── Ledger Table ──────────────────────────────────────────────────────────── */
table.ledger {
  width: 100%;
  border-collapse: collapse;
}
table.ledger th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
  background: var(--paper-2);
}
table.ledger td {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--ink);
}
table.ledger tr:hover td { background: var(--paper-4); }

/* ── Form Controls ─────────────────────────────────────────────────────────── */
.admin-input,
.admin-select,
.admin-textarea {
  width: 100%;
  background: var(--paper-3);
  border: 1px solid var(--line);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  border-radius: 0;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.admin-input:focus,
.admin-select:focus,
.admin-textarea:focus {
  border-color: var(--ink);
  background: var(--paper-4);
}

.admin-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ── Modals ────────────────────────────────────────────────────────────────── */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
}

html.dark .admin-modal-backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.admin-modal-box {
  background: var(--paper-3);
  border: 1px solid var(--line);
  max-width: 480px;
  width: 100%;
}

.admin-modal-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.admin-modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  background: none;
  transition: border-color 0.2s, color 0.2s;
}
.admin-modal-close:hover { border-color: var(--ink); color: var(--ink); }

.admin-modal-body { padding: 28px; }
.admin-modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── QR Modal ──────────────────────────────────────────────────────────────── */
.qr-box {
  background: var(--paper-3);
  border: 1px solid var(--line);
  max-width: 380px;
  width: 100%;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */
.admin-footer {
  padding: 24px 0 8px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-2);
  border-top: 1px solid var(--line);
  margin-top: 48px;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
.admin-main::-webkit-scrollbar { width: 6px; }
.admin-main::-webkit-scrollbar-track { background: var(--paper-2); }
.admin-main::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

/* ── Selection ─────────────────────────────────────────────────────────────── */
html.admin-page ::selection { background: var(--ink); color: var(--paper); }

/* ── Sidebar responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  html.admin-page aside {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  html.admin-page aside.open { transform: translateX(0); }

  /* Hide desktop topbar on mobile */
  #admin-topbar-desktop { display: none !important; }

  /* Stack KPI grid on mobile */
  .admin-content section > div[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 540px) {
  .admin-content section > div[style*="grid-template-columns:repeat(4"],
  .admin-content section > div[style*="grid-template-columns:repeat(2"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Mobile overlay ────────────────────────────────────────────────────────── */
#admin-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 45;
}
#admin-mobile-overlay.active { display: block; }

/* ── Crest chip ────────────────────────────────────────────────────────────── */
.crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-display);
  font-style: normal;
  font-size: 14px;
}

/* ── Desktop Topbar ───────────────────────────────────────────────────────── */
.desktop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

html.dark .desktop-topbar {
  background: var(--paper-2);
  border-bottom-color: var(--line);
}

@media (max-width: 900px) {
  .desktop-topbar { display: none !important; }
}

/* ── Admin Mono Label ─────────────────────────────────────────────────────── */
.admin-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
