/* ==========================================================================
   Demo Mode — loaded ONLY on demo hostnames (see demo_head() in Helpers.php).
   Nothing here can affect the real system: the file is never linked from a
   page served on a non-demo host.

   Two jobs:
   1. Style the always-visible "DEMO MODE" strip (.demo-banner) and the start
      page (.demo-landing).
   2. Make room for that strip. The POS shell is a fixed 100vh kiosk layout
      (no page scroll), the backoffice sidebar/topbar are sticky at top:0 and
      the mobile drawers are position:fixed at top:0, so a strip added above
      them would otherwise push the bottom of each layout off-screen. Every
      such rule is shifted by --demo-h here instead of editing the layouts'
      own stylesheets.
   ========================================================================== */

:root {
  --demo-h: 40px;
  --demo-bar-bg: #ffe7a3;
  --demo-bar-text: #4a3300;
  --demo-bar-border: #e0b94a;
  --demo-badge-bg: #8a5a00;
  --demo-badge-text: #ffffff;
  --demo-btn-bg: rgba(255, 255, 255, 0.62);
  --demo-btn-border: rgba(74, 51, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --demo-bar-bg: #4a3a12;
    --demo-bar-text: #ffe9b0;
    --demo-bar-border: #6d5519;
    --demo-badge-bg: #f0b429;
    --demo-badge-text: #2a1c00;
    --demo-btn-bg: rgba(255, 255, 255, 0.08);
    --demo-btn-border: rgba(255, 233, 176, 0.4);
  }
}

:root[data-theme="dark"] {
  --demo-bar-bg: #4a3a12;
  --demo-bar-text: #ffe9b0;
  --demo-bar-border: #6d5519;
  --demo-badge-bg: #f0b429;
  --demo-badge-text: #2a1c00;
  --demo-btn-bg: rgba(255, 255, 255, 0.08);
  --demo-btn-border: rgba(255, 233, 176, 0.4);
}

/* Touch screens get the app's usual bigger tap targets. */
@media (pointer: coarse) {
  :root { --demo-h: 46px; }
}

/* ---------- The strip ---------- */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 96; /* above the sticky topbar (20) and the mobile drawers (95), below modals (100) */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--demo-h);
  padding: 0 var(--space-4);
  background: var(--demo-bar-bg);
  color: var(--demo-bar-text);
  border-bottom: 1px solid var(--demo-bar-border);
  font-size: var(--text-xs);
  line-height: 1.2;
  overflow: hidden;
}

.demo-banner-main { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }

.demo-badge {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--demo-badge-bg);
  color: var(--demo-badge-text);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.demo-banner-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.demo-banner-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.demo-inline-form { margin: 0; }

.demo-btn {
  min-height: 28px;
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--demo-btn-border);
  background: var(--demo-btn-bg);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.demo-btn:hover { background: var(--demo-badge-bg); border-color: var(--demo-badge-bg); color: var(--demo-badge-text); }
.demo-btn-quiet { background: transparent; }
@media (pointer: coarse) {
  .demo-btn { min-height: 36px; padding: 6px 13px; }
}

@media (max-width: 640px) {
  .demo-hide-sm { display: none; }
  .demo-banner { padding: 0 var(--space-3); gap: var(--space-2); }
}
@media (max-width: 430px) {
  .demo-banner-text { display: none; }
}

/* ---------- Making room for the strip ---------- */

/* POS: fixed kiosk shell, body never scrolls. */
body.demo-mode.pos-body { height: 100vh; }
body.demo-mode .pos-shell { height: calc(100vh - var(--demo-h)); }
body.demo-mode.osk-open .pos-shell { height: calc(100vh - var(--osk-height) - var(--demo-h)); }
body.demo-mode .pos-sidebar { top: var(--demo-h); }

/* Backoffice: sticky sidebar/topbar sit under the sticky strip. */
body.demo-mode .bo-shell { min-height: calc(100vh - var(--demo-h)); }
body.demo-mode.osk-open .bo-shell { min-height: calc(100vh - var(--osk-height) - var(--demo-h)); }
body.demo-mode .bo-sidebar { top: var(--demo-h); height: calc(100vh - var(--demo-h)); }
body.demo-mode .bo-topbar { top: var(--demo-h); }
@media (max-width: 980px) {
  body.demo-mode .bo-sidebar { top: var(--demo-h); bottom: 0; height: auto; }
}

/* Login / start / error pages. */
body.demo-mode .auth-shell { min-height: calc(100vh - var(--demo-h)); }
body.demo-mode.osk-open .auth-shell { min-height: calc(100vh - var(--osk-height) - var(--demo-h)); }
body.demo-mode .auth-theme-toggle { top: calc(var(--demo-h) + var(--space-4)); }
/* On narrow screens the card spans the width, so the layout's fixed
   Dark/Light toggle would sit on top of it — start the card below the toggle. */
@media (max-width: 900px) {
  body.demo-mode .auth-shell { align-items: flex-start; padding-top: 68px; }
}

/* Toasts must not hide under the strip. */
body.demo-mode .toast-stack { top: calc(var(--demo-h) + var(--space-3)); }

/* Phone-friendly dashboard. The stock single-column grid is `1fr`, which is
   really minmax(auto, 1fr): the chart canvas's intrinsic width props the
   column open to ~650px and the whole dashboard scrolls sideways on a phone.
   (Scoped to the demo on purpose — backoffice.css is production code.) */
@media (max-width: 1024px) {
  body.demo-mode .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  body.demo-mode .dashboard-grid > * { min-width: 0; }
}

/* ---------- Guide modal ---------- */
.demo-guide h4 { margin: var(--space-4) 0 var(--space-2); font-size: var(--text-base); }
.demo-guide ol { margin: 0 0 var(--space-4); padding-left: 1.25rem; font-size: var(--text-sm); color: var(--color-text-secondary); }
.demo-guide li { margin-bottom: var(--space-2); }
.demo-guide li strong { color: var(--color-text); }
.demo-guide-lead { font-size: var(--text-sm); color: var(--color-text-secondary); }
.demo-guide-note {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-light);
  color: var(--color-text);
  font-size: var(--text-xs);
}

/* ---------- Start page ---------- */
.demo-landing {
  width: 100%;
  max-width: 820px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-7) var(--space-6);
}

.demo-landing-head { text-align: center; margin-bottom: var(--space-5); }
.demo-landing-head .auth-logo { display: block; max-width: 130px; height: auto; margin: 0 auto var(--space-3); border-radius: var(--radius-md); }
.demo-landing-head h1 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.demo-lead { max-width: 560px; margin: 0 auto; color: var(--color-text-secondary); font-size: var(--text-sm); }

.demo-notice {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-warning-light);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.demo-resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  background: var(--color-primary-light);
}
.demo-resume strong { display: block; }
.demo-resume-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.demo-or { margin: var(--space-4) 0 0; text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); }

.demo-personas { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin: var(--space-5) 0; }

.demo-persona {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-5);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.demo-persona h2 { margin: 0; font-size: var(--text-md); }
.demo-persona p { margin: 0; font-size: var(--text-sm); color: var(--color-text-secondary); }
.demo-persona ul { margin: var(--space-2) 0 var(--space-3); padding-left: 1.1rem; font-size: var(--text-sm); color: var(--color-text-secondary); }
.demo-persona li { margin-bottom: 4px; }
.demo-persona .btn { margin-top: auto; }
.demo-persona-tag {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
}

.demo-safe {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-success-light);
}
.demo-safe h3 { margin: 0 0 var(--space-2); font-size: var(--text-base); color: var(--color-success); }
.demo-safe ul { margin: 0; padding-left: 1.1rem; font-size: var(--text-sm); color: var(--color-text-secondary); }
.demo-safe li { margin-bottom: 6px; }
.demo-safe li strong { color: var(--color-text); }

@media (max-width: 720px) {
  .demo-landing { padding: var(--space-5) var(--space-4); }
  .demo-personas { grid-template-columns: 1fr; }
}
