/* Inter + JetBrains Mono for admin/pair/setup (and any surface that uses .ed-*).
   Customer-display v0.1 falls back gracefully to system/Cairo. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');
/* Stations brand tokens lifted from pwa.edara.io — do not re-derive. */
@import url('./stations-tokens.css');

/* Single source of truth is stations-tokens.css (--ed-*). The old legacy
   :root palette (--primary #0091EA / --bg / --text …) was a second, divergent
   color system; it has been removed and every surface now maps onto --ed-*. */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--ed-canvas); color: var(--ed-text);
  font-family: 'Inter', 'Cairo', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
html[lang^="ar"] body, html[dir="rtl"] body { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }

#app {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "hero   hero"
    "header side"
    "lines  side"
    "pwrd   pwrd";
  height: 100%;
  padding: clamp(12px, 2vw, 24px);
  gap: clamp(10px, 1.5vw, 16px);
}

/* ---------- Hero — clean white header matching CD_Itemized_Hifi ---------- */
.hero {
  grid-area: hero;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  background: var(--ed-card);
  color: var(--ed-text);
  padding: clamp(14px, 2vw, 22px) clamp(16px, 2.5vw, 28px);
  border-radius: var(--ed-radius-lg);
  border: 1px solid var(--ed-border);
  box-shadow: var(--ed-shadow-card);
}
.hero-main { display: flex; align-items: center; gap: 18px; min-width: 0; }
.hero-logo { display: inline-flex; align-items: center; }
.hero-logo img { height: 28px; width: auto; display: block; }
.hero-tenant { min-width: 0; }
.hero-side { text-align: end; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.station-badge { display: inline-flex; align-items: center; gap: 8px; }
.station-badge:empty { display: none; }
.tenant-name {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 700; letter-spacing: -0.01em;
  color: var(--ed-text);
}
.tenant-name:empty::after { content: "Edara"; color: var(--ed-navy); }
.welcome {
  margin-top: 2px; font-size: clamp(12px, 1.2vw, 14px);
  color: var(--ed-text-2); font-weight: 400;
}
.welcome:empty { display: none; }
.customer-greeting {
  margin-top: 8px; font-size: clamp(13px, 1.4vw, 16px);
  font-weight: 500;
  background: var(--ed-blue-tint);
  color: var(--ed-navy);
  padding: 4px 12px; border-radius: 999px;
  display: inline-block;
}
.tenant-site {
  font-family: var(--ed-mono);
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ed-text-3);
  white-space: nowrap;
}
.tenant-site:empty { display: none; }
.status {
  font-family: var(--ed-mono);
  font-size: 11px; letter-spacing: 0.05em;
  color: var(--ed-text-3);
}
.status.live::before {
  content: "● ";
  color: var(--ed-ok);
}

.wake-toggle {
  margin-top: 6px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--ed-text-2);
  border: 1px solid var(--ed-border);
  border-radius: 999px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;            /* WCAG 2.5.5 — kiosk/tablet touch target */
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.wake-toggle:hover { border-color: var(--ed-navy); color: var(--ed-navy); }
.wake-toggle.active {
  background: var(--ed-ok-soft);
  border-color: var(--ed-ok);
  color: var(--ed-ok);
}
.wake-toggle .wake-icon { font-size: 14px; line-height: 1; }
.wake-toggle[hidden] { display: none; }

/* ---------- Items header ---------- */
.lines-header {
  grid-area: header;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 6px;
  color: var(--ed-text-3);
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 500;
}
.lines-header #itemsCount {
  color: var(--ed-navy); font-weight: 700; font-size: 13px;
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
  background: var(--ed-blue-tint); padding: 2px 10px; border-radius: 999px;
}
.lines-header[hidden] { display: none; }

/* ---------- Lines ---------- */
.lines {
  grid-area: lines;
  background: var(--ed-card);
  border-radius: var(--ed-radius-lg);
  box-shadow: var(--ed-shadow-card);
  border: 1px solid var(--ed-border);
  overflow: auto; padding: 6px 4px;
  /* Grid items default to min-content height; without this a long list grows
     the 1fr track instead of scrolling inside this container. */
  min-height: 0;
}
.lines .empty {
  text-align: center; color: var(--ed-text-3);
  padding: clamp(40px, 6vw, 80px) 16px;
  font-size: clamp(14px, 1.5vw, 16px); font-weight: 400;
}
.pair-link {
  color: var(--ed-navy);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Empty-state modifier — used by station pages to override the default dim/italic
   "no items yet" styling when the slot is repurposed as a "Pair this device" CTA. */
.kds-empty.pair-cta { color: rgba(255,255,255,0.85); font-style: normal; }
.line {
  display: grid; grid-template-columns: 52px 1fr auto;
  align-items: baseline; gap: clamp(8px, 1.2vw, 14px);
  padding: clamp(10px, 1.2vw, 14px);
  border-bottom: 1px solid var(--ed-border);
}
.line:last-child { border-bottom: 0; }
.thumb {
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(16px, 1.6vw, 18px);
  font-weight: 600; color: var(--ed-navy);
  text-align: center;
  letter-spacing: 0;
  background: transparent;
}
.thumb::after { content: "×"; opacity: 0.6; margin-inline-start: 1px; }
.desc { min-width: 0; }
.desc .name {
  font-weight: 500; font-size: clamp(14px, 1.4vw, 16px);
  color: var(--ed-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.desc .sku {
  font-family: var(--ed-mono);
  font-size: 11px; color: var(--ed-text-3); margin-top: 2px;
}
.qty { display: none; }
.amount {
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500; font-size: clamp(14px, 1.4vw, 16px);
  color: var(--ed-text);
}

/* ---------- Side ---------- */
.side { grid-area: side; display: flex; flex-direction: column; gap: clamp(10px, 1.5vw, 16px); }

.payments {
  background: var(--ed-card);
  border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius-lg);
  padding: clamp(12px, 1.4vw, 16px) clamp(14px, 1.8vw, 22px);
  box-shadow: var(--ed-shadow-card);
}
.payments .label {
  font-size: 11px; text-transform: uppercase; color: var(--ed-text-3);
  letter-spacing: 0.08em; margin-bottom: 8px; font-weight: 500;
}
.payments ul { list-style: none; margin: 0; padding: 0; }
.payments li {
  display: flex; justify-content: space-between; padding: 5px 0;
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.payments .row.change {
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--ed-border);
  padding-top: 8px; margin-top: 8px;
  font-weight: 600; color: var(--ed-ok);
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
}

.totals {
  background: var(--ed-card);
  border: 1px solid var(--ed-border);
  border-radius: var(--ed-radius-lg);
  padding: clamp(14px, 1.6vw, 18px) clamp(16px, 2vw, 24px);
  box-shadow: var(--ed-shadow-card);
}
.totals .row {
  display: flex; justify-content: space-between;
  padding: 5px 0; font-size: 13px;
  color: var(--ed-text-3);
}
.totals .row span:first-child {
  font-size: 12px; letter-spacing: 0.02em;
}
.totals .row span:last-child {
  font-family: var(--ed-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ed-text-2); font-weight: 500;
}
.totals .row.grand {
  border-top: 2px solid var(--ed-navy);
  margin-top: 10px; padding-top: 14px;
  align-items: baseline;
}
.totals .row.grand span:first-child {
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 700;
  color: var(--ed-text);
  letter-spacing: -0.01em;
  text-transform: none;
}
.totals .row.grand span:last-child {
  font-family: var(--ed-mono);
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 700;
  color: var(--ed-navy);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* ---------- Powered by ---------- */
.powered {
  grid-area: pwrd;
  text-align: center; color: var(--ed-text-3);
  font-size: 11px; letter-spacing: 0.05em;
  opacity: 0.85;
}
.powered span { color: var(--ed-navy); font-weight: 600; }

/* ---------- Banner ---------- */
.banner {
  position: fixed; top: 16px; inset-inline-end: 16px;
  background: var(--ed-hot); color: #fff;
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--ed-shadow-lift);
}
.banner[hidden] { display: none; }

/* ---------- RTL ---------- */
html[dir="rtl"] .hero { flex-direction: row-reverse; }
html[dir="rtl"] .hero-side { text-align: start; align-items: flex-start; }

/* ---------- Responsive ---------- */
/* Desktop + wide tablet stays 2-column with side panel on the right. */
@media (max-width: 900px) {
  /* Stack side under lines; lines holds the 1fr scroll row so the items list
     fills remaining height and the totals card sits at its content size. */
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    grid-template-areas: "hero" "header" "lines" "side" "pwrd";
  }
}
@media (max-width: 720px) {
  /* Small tablet / phone landscape — tighten paddings so the hero doesn't
     hog screen real estate meant for the items list. */
  #app { padding: clamp(8px, 1.6vw, 16px); gap: clamp(8px, 1.2vw, 12px); }
  .hero { padding: 12px 16px; }
  .hero-tenant h1 { font-size: clamp(16px, 2.4vw, 20px); }
}
@media (max-width: 520px) {
  /* Phone portrait. */
  .hero { flex-direction: column; align-items: flex-start; gap: 10px; }
  .hero-side { align-items: flex-start; text-align: start; }
  .line { grid-template-columns: 40px 1fr auto; padding: 10px; }
  .thumb { font-size: 15px; }
}
@media (max-width: 360px) {
  /* Tiny phone / split-screen — drop the thumb column entirely. */
  .line { grid-template-columns: 1fr auto; }
  .line .thumb { display: none; }
}
