/* =====================================================================
 * RockAuth styles — admin-spa login + session UI
 * =====================================================================
 * Loaded alongside admin.css. All rules namespaced under `.rock-auth-*`
 * to avoid collisions with the existing kiosk admin styles.
 *
 * Uses the same design tokens (--bg, --surface, --accent, --fg, etc.)
 * as the rest of the system, so it inherits whatever theme tokens.css
 * has applied.
 * ===================================================================== */

/* Global [hidden] override.
 *
 * Author rules with `display: flex` / `display: grid` win over the UA
 * stylesheet's `[hidden] { display: none }` on specificity ties — so
 * an element with `hidden` set still renders. !important fixes that
 * for everything inside the admin SPA. (Same fix we applied to the
 * till SPA — same root cause.) */
[hidden] { display: none !important; }

/* ---------- Topbar staff chip ---------- */

#rock-auth-topbar {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-right: 12px;
  font-size: 13px;
}

.rock-auth-staff {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.rock-auth-staff-name {
  font-weight: 600;
  color: var(--fg);
}

.rock-auth-login-btn,
.rock-auth-logout-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--fg-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.rock-auth-login-btn:hover,
.rock-auth-logout-btn:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}
.rock-auth-login-btn {
  background: var(--accent);
  color: var(--accent-fg, #1a1a1a);
  border-color: var(--accent);
}

/* ---------- Toast notifications ---------- */

#rock-auth-notif {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.rock-auth-toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  max-width: 380px;
  transition: opacity 0.3s;
}
.rock-auth-toast[data-severity="warning"] { border-left: 4px solid var(--warn, #f5a623); }
.rock-auth-toast[data-severity="error"]   { border-left: 4px solid var(--danger, #c44); }
.rock-auth-toast[data-severity="success"] { border-left: 4px solid var(--tip-green, #4caf50); }

/* ---------- Modal shell ---------- */

.rock-auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.rock-auth-modal {
  background: var(--surface);
  border-radius: 12px;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.rock-auth-modal-narrow { width: min(420px, 100%); }
.rock-auth-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.rock-auth-modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--display, inherit);
}
.rock-auth-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--fg-dim);
  cursor: pointer;
  border-radius: 6px;
}
.rock-auth-modal-close:hover { background: var(--bg); color: var(--fg); }

.rock-auth-modal-body {
  padding: 16px 24px 24px;
  overflow-y: auto;
  display: flex;
  align-items: stretch;     /* let columns share equal height naturally */
  gap: 24px;
}
/* Staff list takes whatever space is left after the PIN area. The
 * staff tiles flex-wrap inside it. When the PIN area is hidden, the
 * list naturally fills the modal width. */
.rock-auth-modal-body > .rock-auth-staff-list {
  flex: 1 1 auto;
  min-width: 0;
}
/* The PIN area sits to the right at a fixed 320px when present. When
 * hidden (no staff yet picked, or no admin-eligible staff at all), it
 * contributes nothing to the layout — modal collapses to staff list
 * only. The `[hidden]` rule at top of the file hides it; we just
 * ensure its width when shown. */
.rock-auth-modal-body > .rock-auth-pin-area {
  flex: 0 0 320px;
}
.rock-auth-modal-narrow .rock-auth-modal-body {
  flex-direction: column;
}
.rock-auth-modal-narrow .rock-auth-modal-body > .rock-auth-pin-area {
  flex: 1 1 auto;
  align-self: center;
}

/* ---------- Staff picker ---------- */

.rock-auth-staff-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  align-content: start;
}
.rock-auth-staff-tile {
  /* Each tile carries its owner's palette colour, same convention as
   * the till login tiles: admin-auth.js sets --staff-color to the
   * staff member's --staff-<token>; no token → accent fallback.
   * Border + name render in the colour; selected fills with it. */
  --staff-color: var(--accent);
  background: var(--surface2);
  border: 2px solid var(--staff-color);
  border-radius: 8px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
  /* Constrain max width so a single tile doesn't stretch absurdly
   * wide on a 720px modal — keeps the visual scale right whether
   * there's 1 staff member or 12. */
  max-width: 200px;
  /* Visual lift so the tile reads as raised against the surface */
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.rock-auth-staff-tile:hover {
  background: var(--surface);
  transform: translateY(-1px);
}
.rock-auth-staff-tile:active { transform: translateY(0); }
.rock-auth-staff-tile[data-selected="true"] {
  background: var(--staff-color);
  color: #fff;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--staff-color);
}
.rock-auth-staff-tile-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--staff-color);
}
.rock-auth-staff-tile[data-selected="true"] .rock-auth-staff-tile-name {
  color: #fff;
}
.rock-auth-staff-tile-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.rock-auth-loading,
.rock-auth-empty {
  text-align: center;
  padding: 32px;
  color: var(--muted, var(--fg-dim));
  font-size: 13px;
}
.rock-auth-empty {
  text-align: left;
  padding: 16px 8px;
}
.rock-auth-empty h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--accent);
  font-family: var(--display, inherit);
}
.rock-auth-empty p {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
}
.rock-auth-empty pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg);
  overflow-x: auto;
  user-select: all;
  white-space: pre-wrap;
  margin: 8px 0 12px;
}
.rock-auth-empty-hint {
  font-style: italic;
  color: var(--fg-dim);
  font-size: 12px !important;
}

/* ---------- PIN keypad ---------- */

.rock-auth-pin-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
/* Placeholder shown while no staff is picked. Sized so the modal
 * doesn't shrink/grow when the keypad takes over (the keypad is
 * roughly 290px tall: 4 rows × 56px + gaps + prompt + dots). */
.rock-auth-pin-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  color: var(--fg-dim);
  font-style: italic;
  padding: 24px 16px;
  border: 1px dashed var(--border2);
  border-radius: 8px;
  background: var(--surface2);
  width: 100%;
  /* Match the rough height of the live keypad so the modal doesn't
   * resize when the user picks a staff. */
  min-height: 290px;
}
/* Live keypad section. Lays out the same as before but no longer
 * inherits flex-centering from a parent — it sits naturally at the
 * top of the column. */
.rock-auth-pin-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.rock-auth-pin-prompt {
  text-align: center;
  font-size: 13px;
  color: var(--fg-dim);
}
.rock-auth-pin-display {
  display: flex;
  gap: 8px;
}
.rock-auth-pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: all 0.12s;
}
.rock-auth-pin-dot[data-filled="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
.rock-auth-pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 6px;
}
.rock-auth-pin-keypad button {
  height: 56px;
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.08s;
}
.rock-auth-pin-keypad button:active {
  transform: scale(0.95);
  background: var(--accent);
  color: var(--accent-fg, #1a1a1a);
  border-color: var(--accent);
}
.rock-auth-pin-error {
  color: var(--danger, #c44);
  font-size: 12px;
  text-align: center;
}

/* Admin embedded in the till's Add product sheet (v1.5.163): only the
   wizard shows. Everything else on the page is hidden, the wizard fills
   the sheet, and there's nothing behind it to click. */
html.embed-wizard body > *:not(.rock-auth-modal-overlay) { display: none !important; }
html.embed-wizard, html.embed-wizard body { background: var(--embed-bg, var(--bg, #14121c)); }
html.embed-wizard .rock-auth-modal-overlay { background: transparent; align-items: stretch; justify-content: center; padding: 10px; }
/* Full size, like every other till sheet (v1.5.167). */
html.embed-wizard .rock-auth-modal { max-height: none; height: calc(100vh - 20px); width: 100%; }
html.embed-wizard [data-wiz-action="save-and-modifiers"] { display: none !important; }

/* …and dressed as a till sheet (v1.5.167). admin-embed.js measures a
   real till sheet (card, header, title, ×, buttons, inputs) in the
   till's current theme and hands the numbers over as --t-* variables;
   these rules put them on the wizard. Fallbacks = the till's defaults. */
html.embed-wizard .rock-auth-modal {
  background: var(--t-card-bg, var(--surface)); color: var(--fg); font-family: var(--body);
  border-radius: var(--t-card-radius, 12px); border: var(--t-card-border, 0); box-shadow: var(--t-card-shadow, none);
}
html.embed-wizard .pmodal-head {
  align-items: center; min-height: var(--t-head-min-h, 64px); padding: var(--t-head-pad, 10px 12px 10px 24px);
  background: var(--t-head-bg, var(--surface)); border-bottom: var(--t-head-border, 1px solid var(--border)); box-sizing: border-box;
}
html.embed-wizard .pmodal-head h2 {
  margin: 0; color: var(--t-title-color, var(--accent)); text-shadow: var(--t-title-shadow, none);
  font-family: var(--t-title-font, var(--display)); font-size: var(--t-title-size, 20px);
  font-weight: var(--t-title-weight, 700); letter-spacing: var(--t-title-spacing, normal);
}
html.embed-wizard .pmodal-head .hint { font-size: 13px; color: var(--fg-dim); margin-top: 2px; }
html.embed-wizard .pmodal-close {
  display: flex; align-items: center; justify-content: center;
  width: var(--t-close-w, 44px); height: var(--t-close-w, 44px); border-radius: var(--t-close-radius, 8px);
  font-size: var(--t-close-size, 30px); color: var(--t-close-color, var(--fg-dim)); background: transparent;
}
html.embed-wizard .pmodal-close:hover { background: var(--bg); color: var(--fg); }
html.embed-wizard .pmodal-body { padding: 16px 24px; }
html.embed-wizard .pmodal-body label, html.embed-wizard .pmodal-body .field > span { font-size: 13px; font-weight: 600; color: var(--fg-dim); text-transform: none; letter-spacing: 0; }
html.embed-wizard .pmodal-body input:not([type=checkbox]):not([type=radio]),
html.embed-wizard .pmodal-body select,
html.embed-wizard .pmodal-body textarea {
  background: var(--t-input-bg, var(--bg)); color: var(--fg);
  border: 2px solid var(--t-input-border, var(--border)); border-radius: 10px;
  font-size: 18px; padding: 10px 14px; min-height: 48px; font-family: var(--body);
}
html.embed-wizard .pmodal-body input:focus, html.embed-wizard .pmodal-body select:focus { outline: none; border-color: var(--accent); }
html.embed-wizard .modal-section h3 { font-size: 15px; letter-spacing: 0.04em; }
html.embed-wizard .wiz-tile { background: transparent; border: 1px solid var(--border); border-radius: 10px; padding: 18px 16px; min-height: 60px; justify-content: center; }
html.embed-wizard .wiz-tile:hover { border-color: var(--accent); background: transparent; }
html.embed-wizard .wiz-tile-title { font-size: 18px; letter-spacing: 0; }
html.embed-wizard .pmodal-foot { padding: 12px 16px; background: var(--t-card-bg, var(--surface)); }
html.embed-wizard .pmodal-foot button {
  min-height: 48px; padding: 0 22px; font-size: 16px; font-weight: 600; border-radius: 10px; font-family: var(--body);
}
html.embed-wizard .pmodal-foot button.primary {
  background: var(--t-btn-bg, var(--accent)); color: var(--t-btn-fg, #fff);
  border: 1px solid var(--t-btn-border, transparent); box-shadow: var(--t-btn-shadow, none);
}
html.embed-wizard .pmodal-foot button.ghost {
  background: transparent; color: var(--t-btn2-fg, var(--fg)); border: 1px solid var(--t-btn2-border, var(--border));
}
html.embed-wizard .allergen-chip { border-radius: 10px; min-height: 48px; }
