/*
static/css/style.css
─────────────────────
Custom CSS for OrderlyOS.
Kept intentionally minimal — Tailwind handles 95% of styling.
This file covers: print styles, custom animations, and a few things Tailwind can't do cleanly.
*/

/* ── Google Font import backup (also in base.html <head>) ─────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

/* ── Base ─────────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; /* removes tap flash on mobile */
}

body {
  font-family: 'DM Sans', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Print styles ─────────────────────────────────────────────────────────── */
/*
  When window.print() is called, ONLY the .ticket div prints.
  Everything else — nav, buttons, app chrome — is hidden.
  This gives a clean receipt/order summary on any printer.
  80mm width suits thermal receipt printers. A4 printers also work cleanly.
*/
@media print {
  /* Hide all app UI */
  nav,
  header,
  .print-hidden,
  button,
  a,
  #flash-messages,
  .no-print {
    display: none !important;
  }

  /* Show only the ticket */
  body {
    background: white !important;
    color: black !important;
    font-family: 'Courier New', monospace;
  }

  .ticket {
    display: block !important;
    width: 80mm;
    max-width: 80mm;
    margin: 0 auto;
    padding: 8mm;
    font-size: 12px;
    color: black;
  }

  /* Make everything else invisible */
  body > *:not(.ticket) {
    display: none !important;
  }
}

/* ── Shared receipt partial (partials/print_receipt.html) ─────────────────── */
/* The partial's layout classes are defined inside @media print (base.html);
   these mirror them for SCREEN so the same fragment reads correctly when
   embedded on a visible page (order_summary receipt preview).              */
.print-receipt .print-row     { display: flex; justify-content: space-between; width: 100%; }
.print-receipt .print-center  { text-align: center; }
.print-receipt .print-bold    { font-weight: 700; }
.print-receipt .print-large   { font-size: 1.05em; }
.print-receipt .print-divider { border-top: 1px dashed currentColor; opacity: .35; margin: 6px 0; }

/* ── Kitchen/Bar card timer colours ──────────────────────────────────────── */
/* These are also set dynamically in JS but defined here as base states */
.timer-green { color: #22c55e; }
.timer-amber { color: #f59e0b; }
.timer-red   { color: #ef4444; }

/* ── PWA standalone mode ─────────────────────────────────────────────────── */
/* Superseded — the safe-area handling now lives in base.css under
   "iOS status bar", which owns the whole problem in one place: the body inset,
   the opaque strip behind the status bar, and where sticky chrome pins to.
   Splitting it across two stylesheets is how the body padding here ended up
   fighting sticky bars that pin to the viewport top regardless of it. */

/* ── Smooth transitions globally ─────────────────────────────────────────── */
a, button {
  transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}
/* Instant on the way IN. A 150ms ease on the press itself reads as lag on a
   touchscreen; the transition above is for the release. */
a:active, button:active, .is-pressed { transition-duration: 0s; }

/* ── Scrollbars: never drawn ─────────────────────────────────────────────── */
/* The app is a touch surface. A visible bar is a desktop affordance nobody in
   service uses: it steals ~10px off the right edge of every screen, and on
   macOS with "always show scroll bars" (and on Windows tablets) it draws a
   grey rail down the side of pages that scroll by a few pixels. Scrolling
   still works everywhere — wheel, trackpad, touch, keyboard — it is only the
   rail that is gone. Applies to the page and to every inner scroller, so a
   panel does not have to remember to add `scrollbar-hide` itself. */
html, body, * {
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* old Edge/IE */
}
::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* ── Kitchen view high contrast override ─────────────────────────────────── */
/*
  Kitchen displays are often in bright, steamy environments.
  These overrides ensure maximum readability at a distance.
*/
.kitchen-view .order-card {
  min-height: 200px;
}

.kitchen-view .mark-ready-btn {
  min-height: 60px;
  font-size: 1.1rem;
}

/* ── Light / Dark theme overrides ─────────────────────────────────────────── */
/* Only things the token layer genuinely cannot express belong here. Colour
   does not — see the note further down. */

/* The "ly" of the wordmark is set in text next to the mark, so it follows the
   text token rather than being flipped per theme by hand. */
.logo-ly { color: var(--text-1); }

/* Modal blur — same treatment in both themes. The scrim behind it is what
   carries legibility, and that is a token. */
.backdrop-blur {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Dividers follow the hairline token in both themes. */
.border-t, .border-b, .border-l, .border-r { border-color: var(--border-1); }

/* ── OrderlyOS logo theme switching ─────────────────────────────────────── */
/* Dark mode (default): show dark wordmark, hide light */
[data-theme="dark"] .orderly-logo-dark  { display: inline; }
[data-theme="dark"] .orderly-logo-light { display: none;   }

/* Light mode: show light wordmark, hide dark */
[data-theme="light"] .orderly-logo-dark  { display: none;   }
[data-theme="light"] .orderly-logo-light { display: inline; }

/* Default fallback (no theme set = dark) */
.orderly-logo-dark  { display: inline; }
.orderly-logo-light { display: none;   }

/* ── Text & surface theming ──────────────────────────────────────────────── */
/*
  Deliberately empty.

  This file used to carry ~100 hand-tuned `[data-theme="light"] .text-white\/N`
  rules, each picking its own grey. Two problems: the greys were chosen one at
  a time so the ramp had steps that were invisibly close and steps that jumped,
  and every rule existed only for light mode, so the two themes drifted apart
  the moment either was touched.

  All of it now lives in the token layer in base.html, where a level is defined
  once and both themes read it from the same rule. Nothing belongs here — and
  in particular, adding a `[data-theme="light"] .some-class` override back into
  this file would out-specify the token layer and silently break light mode for
  that class. Change the token instead.
*/

/* ── Icons — stroke follows the text colour ──────────────────────────────── */
/*
  The role, settings and dashboard icon sets were drawn with hardcoded white
  strokes, which meant every one needed a light-mode inversion rule written by
  hand. Pointing the stroke at `currentColor` instead makes them inherit the
  text token they sit inside, so they theme themselves — and an icon dropped
  into a new screen is correct without anyone remembering to add a rule.

  Accent-coloured parts keep their explicit fill: those carry meaning (the
  active state, the brand mark) rather than being chrome.
*/
.role-icon      :where(line, path, circle, rect, polyline, polygon),
.settings-icon  :where(line, path, circle, rect, polyline, polygon),
.dashboard-icon :where(line, path, circle, rect, polyline, polygon) {
  stroke: currentColor;
}

.role-icon      [fill="white"],
.settings-icon  [fill="white"] { fill: currentColor; }

/* Brand blue is meaning, not chrome — it stays put in both themes. */
:where(.role-icon, .settings-icon, .dashboard-icon) [fill="#2563EB"] {
  fill: var(--accent) !important;
}
:where(.role-icon, .settings-icon, .dashboard-icon) [stroke="#2563EB"] {
  stroke: var(--accent) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   i18n & overflow safety
   ─────────────────────
   The UI runs in EN/IT/ES/PT/DE/FR. Translated labels expand up to ~2.7×
   (e.g. "Save" → "Enregistrer", "No tip" → "Pas de pourboire", "Add" →
   "Hinzufügen"), and ticket/item names are user-typed with no length limit.
   These rules make every layout tolerate that without overlap or clipping.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tailwind's `truncate` only works inside a flex/grid child if the child is
   allowed to shrink. Flex children default to min-width:auto, which blocks
   shrinking — so long names silently push siblings off-layout instead of
   truncating. This makes every existing `truncate` in the app actually work. */
.truncate { min-width: 0; }

/* Buttons whose labels are translated (tip percentages, payment methods,
   auto-close options) sit in fixed grid columns. Long FR/DE/ES labels must
   wrap to a second line — centred, tight leading — rather than overflow the
   pill. Grid rows stretch, so buttons in the same row keep equal heights. */
.tip-percent-btn,
.payment-btn,
.autoclose-btn {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  line-height: 1.15;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Kitchen / bar order cards: each item row is
   [name column (flex-1)] [×qty (flex-shrink-0)].
   Item names and ticket names are user-supplied and unbounded; without
   min-width:0 a long unbroken name pushes the quantity off the card.
   Both views mark rows with data-item-key. Names wrap (kitchen staff must
   read the full item, so wrapping beats truncation here). */
[data-item-key] > div:first-child,
.kitchen-items-list .flex-1,
.bar-items-list .flex-1 {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* The same fix, generalised — because the bug is not specific to those two
   screens, it is what `flex-1` does everywhere.

   A flex child's default `min-width: auto` refuses to shrink below its content.
   So `<div class="flex-1">` holding one long unbroken string — a Stripe reader
   name, a Revolut location, a customer email, a table note — grows the row
   wider than the card and the text spills out the side. The app has 199
   `flex-1` uses and only 58 pair it with `min-w-0`, so the remaining 141 were
   each one long value away from overflowing.

   `break-word` only breaks a word that cannot fit on its own line, so ordinary
   prose and translated labels are untouched; it acts solely on the strings
   that would otherwise overflow. Anything carrying `truncate` still ellipses
   instead, since that rule sets `overflow: hidden`. */
.flex-1 {
  min-width: 0;
  overflow-wrap: break-word;
}
