/* =========================================================
   admin-shell.css  — Logicues Admin Shell
   Design tokens + app-shell layout + nav/topbar.
   Loads BEFORE admin.css. admin.css relies on these tokens.
   Agent A output — do not edit admin.css or admin.js here.
   ========================================================= */

/* =========================================================
   §1  DESIGN TOKENS  (light Logicues palette)
   ========================================================= */
:root {
  /* surfaces */
  --bg-primary:      #f4f1ea;   /* app/page background — warm paper */
  --bg-secondary:    #ffffff;   /* cards / panels */
  --bg-card:         #ffffff;   /* was translucent-on-dark; now solid white card */
  --bg-elevated:     #fbf9f4;   /* subtle raised surface (sidebar, inputs bg) */

  /* text */
  --text-primary:    #1b1712;   /* ink */
  --text-secondary:  #6f6658;   /* warm muted */

  /* brand accents (from welcome.html) */
  --accent-gold:     #e8590c;   /* PRIMARY accent (mango-deep) — name kept for auto-flip */
  --accent-ocean:    #0f9b8e;   /* teal */
  --accent-rose:     #d6336c;   /* berry */
  --accent-gradient: linear-gradient(100deg, #ff7a18 0%, #d6336c 100%);

  /* lines / borders — name kept so existing var(--border-*) refs auto-flip */
  --border-glass:    rgba(20, 18, 14, 0.12);
  --border-soft:     rgba(20, 18, 14, 0.07);

  /* status — contrast-safe on light backgrounds */
  --status-pending:   #e8850c;
  --status-preparing: #0f9b8e;
  --status-served:    #2f6fed;
  --status-completed: #16a34a;
  --status-cancelled: #e11d48;

  /* radii + motion — kept to match existing component usage */
  --border-radius-sm: 12px;
  --border-radius-md: 18px;
  --border-radius-lg: 26px;
  --transition: all .22s cubic-bezier(.2, .7, .2, 1);

  /* shell metrics */
  --lg-sidebar-w:    248px;
  --lg-topbar-h:     60px;

  /* shadows for light UI */
  --shadow-card: 0 1px 2px rgba(20, 18, 14, .04), 0 6px 20px rgba(20, 18, 14, .06);
  --shadow-pop:  0 12px 34px rgba(20, 18, 14, .14);
}

/* =========================================================
   §2  BASE RESET + BODY
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

body.lg-admin {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv01";
}

/* Headings use Bricolage Grotesque — override for admin body scope */
body.lg-admin h1,
body.lg-admin h2,
body.lg-admin h3,
body.lg-admin h4,
body.lg-admin h5,
body.lg-admin h6 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Replace any Cinzel font references with Bricolage */
body.lg-admin [style*="Cinzel"] {
  font-family: 'Bricolage Grotesque', sans-serif !important;
}

/* Very subtle warm paper texture — tasteful, low-opacity, performant */
body.lg-admin::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.3;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}

/* Focus ring — warm accent, accessible */
body.lg-admin :focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 3px;
  border-radius: 6px;
}

/* =========================================================
   §3  APP SHELL LAYOUT
   ========================================================= */

/* Scrim (mobile) — shown when sidebar drawer is open.
   Has the [hidden] attribute by default; JS removes it.
   We only need display:block when NOT hidden — [hidden] already
   sets display:none natively, so we ensure the non-hidden state. */
.lg-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, .42);
  z-index: 399;
}
/* CRITICAL: when the `hidden` attribute is present the scrim must be fully removed.
   Do NOT put `display:block` on the base rule — author CSS overrides the UA
   `[hidden]{display:none}` rule, which left a full-viewport fixed overlay on top of
   the entire page intercepting EVERY click (admin looked fine but was unclickable).
   This keeps it click-through when closed; the drawer JS removes `hidden` to show it. */
.lg-scrim[hidden] {
  display: none;
}

/* Shell grid — sidebar + main content column */
.lg-shell {
  display: grid;
  grid-template-columns: var(--lg-sidebar-w) 1fr;
  min-height: 100vh;
}

/* =========================================================
   §3a  SIDEBAR
   ========================================================= */
.lg-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* Custom scrollbar — subtle */
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
  box-shadow: 2px 0 12px rgba(20, 18, 14, .04);
  /* Safe-area inset for notched devices in landscape */
  padding-left: env(safe-area-inset-left, 0px);
  z-index: 1;
}

.lg-sidebar::-webkit-scrollbar {
  width: 4px;
}
.lg-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 4px;
}
.lg-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* Brand row */
.lg-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  min-height: calc(var(--lg-topbar-h) + 4px);
}

.lg-brand-mark {
  background: url(/logo-mark.svg) center / contain no-repeat;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 6px;
}

.lg-brand-word {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* =========================================================
   §3b  NAV
   ========================================================= */
.lg-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px 20px;
  flex: 1;
}

/* Nav item — MUST default to display:flex so that
   revealPremiumTabs() resetting style.display='' shows flex layout */
.lg-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  min-height: 44px;
  transition: background var(--transition), color var(--transition);
  position: relative;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  /* Prevent text selection on double-tap (mobile) */
  user-select: none;
}

.lg-nav-item:hover {
  background: rgba(232, 89, 12, .07);   /* warm mango tint */
  color: var(--text-primary);
}

/* Active state — filled warm wash, left accent bar */
.lg-nav-item.active {
  background: rgba(232, 89, 12, .11);
  color: var(--accent-gold);
}

.lg-nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-gold);
  border-radius: 0 3px 3px 0;
}

/* Icon slot — fixed width so labels always align */
.lg-nav-ico {
  width: 22px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  line-height: 1;
}

/* Label */
.lg-nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Premium section divider */
.lg-nav-sep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 4px;
  color: var(--text-secondary);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .7;
}

.lg-nav-sep::before {
  content: "";
  display: block;
  flex: 1;
  height: 1px;
  background: var(--border-glass);
  opacity: .6;
}

.lg-nav-sep span {
  color: var(--accent-ocean);
  flex: none;
}

/* =========================================================
   §3c  MAIN COLUMN
   ========================================================= */
.lg-main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;       /* allows content to shrink below intrinsic width */
  min-height: 100vh;
  overflow: hidden;
}

/* =========================================================
   §3d  TOPBAR
   ========================================================= */
.lg-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--lg-topbar-h);
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(251, 249, 244, .92);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.lg-topbar-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Topbar actions row */
.lg-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Action buttons — pill style */
.lg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1.5px solid var(--border-glass);
  background: var(--bg-secondary);
  border-radius: 999px;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 36px;
  min-width: 36px;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.lg-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-glass);
  box-shadow: var(--shadow-card);
}

.lg-action-label {
  /* may be hidden on narrow screens — see §5 responsive */
}

/* Danger variant — logout */
.lg-action-btn.lg-action-danger {
  border-color: rgba(225, 29, 72, .22);
  color: #b91c1c;
}

.lg-action-btn.lg-action-danger:hover {
  background: rgba(225, 29, 72, .08);
  border-color: rgba(225, 29, 72, .38);
  color: #991b1b;
}

/* Live pill — WebSocket status indicator */
.lg-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  background: rgba(22, 163, 74, .10);
  color: #15803d;
  border: 1.5px solid rgba(22, 163, 74, .22);
  white-space: nowrap;
}

/* When [hidden] attribute is set, browser already hides it — be explicit */
.lg-live-pill[hidden],
.lg-action-btn[hidden] {
  display: none;
}

.lg-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  animation: lg-pulse 2.2s infinite;
  flex: none;
}

@keyframes lg-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); }
  70%       { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
}

.lg-live-text {
  /* label text beside the dot */
}

/* =========================================================
   §4  HAMBURGER (mobile only — hidden on desktop)
   ========================================================= */
.lg-hamburger {
  display: none;   /* shown only on mobile via media query */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border-glass);
  background: var(--bg-secondary);
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.lg-hamburger:hover {
  background: var(--bg-elevated);
  border-color: var(--border-glass);
}

/* The three bars */
.lg-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform .22s cubic-bezier(.2, .7, .2, 1),
              opacity .22s cubic-bezier(.2, .7, .2, 1);
}

/* =========================================================
   §5  MAIN SCROLL AREA
   ========================================================= */
main.lg-main {
  flex: 1;
  min-width: 0;
  padding: clamp(16px, 3vw, 28px);
  padding-bottom: max(clamp(16px, 3vw, 28px), env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

/* =========================================================
   §6  RESPONSIVE — MOBILE / TABLET  (< 900px)
   ========================================================= */
@media (max-width: 900px) {

  /* Collapse grid to single column — sidebar is off-canvas */
  .lg-shell {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a fixed slide-in drawer */
  .lg-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(84vw, 300px);
    height: 100vh;
    height: 100dvh;    /* dynamic viewport height for mobile browsers */
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.2, .7, .2, 1),
                box-shadow .3s cubic-bezier(.2, .7, .2, 1);
    z-index: 400;
    box-shadow: none;
    /* bottom safe-area for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Open state (JS toggles .open) */
  .lg-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-pop), 4px 0 24px rgba(20, 18, 14, .10);
  }

  /* Show hamburger on mobile */
  .lg-hamburger {
    display: flex;
  }

  /* Main column takes full width */
  .lg-main-col {
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Topbar: add left padding for safe area on notched phones */
  .lg-topbar {
    padding-left: max(20px, env(safe-area-inset-left, 20px));
    padding-right: max(20px, env(safe-area-inset-right, 20px));
  }
}

/* Very narrow phones: hide action button labels — icon only to prevent crowding */
@media (max-width: 560px) {
  .lg-action-label {
    display: none;
  }

  /* But keep buttons at least 44×44 tap target */
  .lg-action-btn {
    padding: 7px 10px;
    min-width: 44px;
    justify-content: center;
  }
}

/* =========================================================
   §7  REDUCED MOTION SUPPORT
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .lg-sidebar {
    transition: none;
  }
  .lg-live-dot {
    animation: none;
  }
  .lg-nav-item,
  .lg-action-btn,
  .lg-hamburger,
  .lg-hamburger span {
    transition: none;
  }
}
