/* Shared styles for the tenant admin and platform (super admin) pages. */
:root {
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 68px;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --sidebar-bg: #171b26;
  --sidebar-text: #a8adb8;
  --sidebar-active-bg: #262b3a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0; background: var(--bg); color: var(--text); }

/* ---- app shell: sidebar (checkbox-hack for the mobile overlay, no JS) ---- */
.app-shell { min-height: 100vh; }
.sidebar-toggle { display: none; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 100;
  transform: translateX(-100%); transition: transform .22s ease, width .18s ease;
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; }
.sidebar-toggle:checked ~ .sidebar { transform: translateX(0); }
.sidebar-toggle:checked ~ .sidebar-backdrop { display: block; }

.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px; flex-shrink: 0; }
.sidebar-brand .name { font-weight: 700; color: #fff; font-size: 15px; }
.sidebar-brand .sub { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; }
/* Lets admin/staff notice at a glance — from anywhere in the panel, since
   this sits in the sidebar brand area every page shares — whether the
   operating-hours setting is currently resulting in the store showing as
   open or closed to customers, in case it was configured wrong. */
.open-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; margin-top: 6px; }
.open-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.open-badge.open { background: rgba(46,204,113,.16); color: #4ade80; }
.open-badge.closed { background: rgba(231,76,60,.18); color: #f87171; }
.sidebar-close { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 4px; }
.sidebar-close svg { width: 20px; height: 20px; display: block; }
.sidebar-collapse-btn { display: none; background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 4px; flex-shrink: 0; }
.sidebar-collapse-btn svg { width: 18px; height: 18px; display: block; transition: transform .18s ease; }

.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; padding: 16px 16px 6px; }
.sidebar-nav {
  flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 12px;
  scrollbar-width: thin; scrollbar-color: transparent transparent;
}
/* Thumb only turns visible while the pointer is actually over the nav
   list (or over the thumb itself) — reserved scrollbar width never
   changes, so revealing it never shifts the nav-link layout. */
.sidebar-nav:hover { scrollbar-color: rgba(255,255,255,.25) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar-nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin: 2px 8px;
  border-radius: 8px; color: var(--sidebar-text); text-decoration: none; font-size: 14px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: #fff; }

.sidebar-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .u { font-size: 13px; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .r { font-size: 11px; color: var(--sidebar-text); }
.sidebar-user form { margin: 0; }
.sidebar-user button { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 6px; }
.sidebar-user button svg { width: 17px; height: 17px; display: block; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.push-toggle-btn { padding: 7px 12px; font-size: 12px; white-space: nowrap; }
.push-toggle-btn svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 2px; }
/* Off by default (matches the "Aktifkan Notifikasi" default label) — the
   diagonal slash line through the bell, not a separate X badge. Hidden
   once .on is toggled on by push-client.js. */
.push-toggle-btn .bell-slash { display: inline; }
.push-toggle-btn.on .bell-slash { display: none; }
.push-toggle-btn.on { background: rgba(46,204,113,.12); color: #1e7a34; border-color: rgba(46,204,113,.4); }
/* Narrow phones: keep just the bell, drop the label text so it can't
   crowd out the page title next to it. */
@media (max-width: 480px) { .push-toggle-btn .label { display: none; } .push-toggle-btn { padding: 7px 9px; } }
/* Busy state while subscribe/unsubscribe is talking to the push service —
   it can take several seconds on mobile, and without feedback users kept
   re-tapping mid-flight. Bell icon swaps for a spinner; taps are ignored. */
.push-busy { opacity: .75; pointer-events: none; }
.push-busy svg { display: none !important; }
.push-busy::before { content: ''; display: inline-block; width: 12px; height: 12px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; vertical-align: -2px; margin-right: 4px; animation: pushSpin .7s linear infinite; }
@keyframes pushSpin { to { transform: rotate(360deg); } }

/* "Install this app" nudge — a slim strip at the very top of the page
   (matching how commerce sites like Lapakgaming/Tokovoucher place theirs),
   revealed by pwa-install.js on mobile browsers only. In normal document
   flow, so it scrolls away with the page instead of covering anything.
   Closing it deliberately only lasts for the current page view — it
   returns on the next load until the app is actually installed
   (standalone mode), per the owner's request. */
.pwa-install-banner { display: none; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(120deg, var(--sidebar-bg), #2b3a67); color: #fff; padding: 10px 14px; }
.pwa-install-banner.show { display: flex; animation: pwaBannerIn .3s ease; }
@keyframes pwaBannerIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.pwa-install-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pwa-install-text strong { font-size: 14px; }
.pwa-install-text span { color: var(--sidebar-text); font-size: 12px; }
.pwa-install-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pwa-install-btn { background: #fff; color: var(--sidebar-bg); border: none; border-radius: 999px; padding: 8px 18px; font-weight: 700; font-size: 13px; cursor: pointer; }
.pwa-install-close { background: none; border: none; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }

/* Guided "how to install" popup — replaces the browser's raw alert() when
   the one-tap install prompt isn't available (install already pending, or
   iOS which has no programmatic prompt at all). Steps are filled in by
   pwa-install.js per platform. */
.pwa-help-overlay { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.5); align-items: center; justify-content: center; padding: 24px; }
.pwa-help-overlay.show { display: flex; }
.pwa-help-box { background: var(--surface); color: var(--text); border-radius: 14px; padding: 20px; max-width: 340px; width: 100%; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.pwa-help-box strong { font-size: 16px; }
.pwa-help-box ol { margin: 0; padding-left: 20px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.pwa-help-note { margin: 0; font-size: 12px; color: var(--text-muted); }
.pwa-help-box .pwa-install-btn { background: var(--accent); color: #fff; align-self: flex-end; }
.hamburger { display: flex; cursor: pointer; color: var(--text); }
.hamburger svg { width: 22px; height: 22px; }
.topbar-title { font-weight: 700; font-size: 16px; }

main.content { max-width: 1100px; margin: 0 auto; padding: 20px 20px 60px; }

@media (min-width: 900px) {
  .sidebar { transform: none; position: fixed; }
  .main { margin-left: var(--sidebar-w); transition: margin-left .18s ease; }
  .hamburger, .sidebar-close { display: none; }
  .sidebar-backdrop { display: none !important; }
  .sidebar-collapse-btn { display: flex; }

  /* Collapsed state — desktop only (persisted via localStorage, applied to
     <html> before paint, see layout_admin.html). Icon-only rail: hides
     every text label but keeps icons/avatar, so nav is still usable at a
     glance, just narrower. Mobile's drawer (checkbox-hack) is completely
     separate machinery and is untouched by any of this. */
  :root.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  :root.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
  :root.sidebar-collapsed .sidebar-brand { justify-content: center; }
  :root.sidebar-collapsed .sidebar-brand-text,
  :root.sidebar-collapsed .nav-section,
  :root.sidebar-collapsed .nav-link span,
  :root.sidebar-collapsed .sidebar-user .who { display: none; }
  :root.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
  :root.sidebar-collapsed .nav-link { justify-content: center; margin: 2px 6px; }
  :root.sidebar-collapsed .sidebar-user { justify-content: center; padding: 14px 8px; }
}

/* ---- content: cards, tables, forms, buttons, pills ---- */
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 9px 10px; font-size: 15px; border: 1px solid #d1d5db; border-radius: 6px; margin-top: 4px;
}
label { display: block; font-size: 13px; color: #555; margin-top: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

button, .btn { padding: 9px 14px; font-size: 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
button.danger { background: #fff; color: #c0392b; border-color: #c0392b; }
.link-btn { background: none; border: none; color: var(--accent); padding: 0; font-size: 12px; display: block; margin-top: 2px; cursor: pointer; text-decoration: underline; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eee; }
.pill.new { background: #ffe6b3; }
.pill.cooking { background: #b3d9ff; }
.pill.served { background: #c6f0c2; }
.pill.done { background: #ddd; color: #888; }
.pill.paid { background: #c6f0c2; }
.pill.pending { background: #ffe6b3; }
.pill.active { background: #c6f0c2; }
.pill.suspended { background: #f5c6c6; }

.empty { color: #888; padding: 12px 0; }
.error { background: #fdecea; color: #c0392b; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.success { background: #e8f7e6; color: #1e7a34; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.tablewrap { overflow-x: auto; }
.mono { font-family: "Courier New", monospace; word-break: break-all; }
.copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: none; background: none; color: #888; cursor: pointer; vertical-align: middle; padding: 0; }
.copy-btn svg { width: 14px; height: 14px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px !important; vertical-align: middle; }
.icon-btn svg { width: 16px; height: 16px; }
.copy-btn:hover { color: #333; }

/* ---- menu item cards (replaces the old table, which needed horizontal
   scrolling to reach the action buttons on narrow screens) ---- */
.menu-list { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) {
  /* Full-width cards look fine on a phone (that's the width they were
     designed for) but leave a huge dead strip of empty space stretched
     across a desktop screen — auto-fill lets the grid fit as many
     ~340px-ish cards per row as the viewport allows with no hardcoded
     column count, so it adapts to any desktop width without a second
     breakpoint. */
  .menu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); align-items: start; }
}
.menu-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.menu-card-top { display: flex; gap: 12px; }
.menu-card-info { flex: 1; min-width: 0; }
.menu-card-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-card-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.menu-card-desc { font-size: 12px; color: #666; margin-top: 4px; }
.menu-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.menu-actions .compact { padding: 6px 10px; font-size: 12.5px; }
.inline-form { margin: 0; display: inline-flex; }
.menu-more { position: relative; }
.menu-more-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); display: none; flex-direction: column;
  min-width: 130px; overflow: hidden;
}
.menu-more-dropdown.show { display: flex; }
.menu-more-dropdown form { margin: 0; }
.menu-more-dropdown button {
  width: 100%; text-align: left; border: none; background: none; color: var(--text);
  border-radius: 0; padding: 10px 14px; font-size: 13px;
}
.menu-more-dropdown button.danger { color: #c0392b; }
.menu-more-dropdown button:hover { background: var(--bg); }

/* ---- category/status filter chips above the menu list ---- */
.filter-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; -ms-overflow-style: none; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- overlay/modal (barcode scanner) ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 30; }
.overlay.show { display: flex; }
.sheet { background: var(--surface); width: 100%; max-width: 380px; border-radius: 12px; padding: 18px; margin: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.sheet h3 { margin-top: 0; }
/* icon-camera's SVG has no explicit width/height (only viewBox), so without
   this it falls back to the browser's oversized default replaced-element
   size — every other icon usage in this file has an equivalent rule. */
#cameraBtn { padding: 6px 10px; font-size: 13px; }
#cameraBtn svg { width: 16px; height: 16px; flex-shrink: 0; }
.scan-video-wrap { position: relative; border-radius: 8px; overflow: hidden; background: #000; }
.scan-video-wrap video { width: 100%; display: block; }
.scan-hint { font-size: 13px; color: var(--text-muted); margin-top: 10px; text-align: center; }
.sheet-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---- stat cards (dashboard) ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.stat-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.bg-indigo { background: #eef0ff; color: #4f46e5; }
.bg-green { background: #e6f7ee; color: #0e9f6e; }
.bg-amber { background: #fef6e7; color: #c27803; }
.bg-red { background: #fdecea; color: #c0392b; }

/* ---- standalone pages: login ---- */
.loginwrap { max-width: 360px; margin: 60px auto; padding: 0 16px; }
.loginwrap h1 { font-size: 20px; margin: 0 0 4px; }
.loginwrap p.sub { color: #666; font-size: 13px; margin: 0 0 16px; }
.loginwrap button { width: 100%; margin-top: 20px; padding: 11px; font-size: 15px; }

@media (max-width: 600px) { main.content { padding: 14px 14px 60px; } }
