/* ==========================================================================
   Retalia AI POS - design tokens & base styles (white clean design)
   Brand purple #b27bfb on white; coral = destructive, mint = confirm/pay.
   Accessibility kept: 48px+ targets, visible focus, contrast & text-scale
   preferences, reduced motion.
   ========================================================================== */

:root {
    /* surfaces (light, clean) */
    --bg: #ffffff;
    --bg-soft: #f5f5f7;
    --surface: #ffffff;
    --surface-2: #fbfbfc;
    --surface-3: #f2f2f4;
    --border: #ececf0;

    /* text */
    --text: #1a1a1a;
    --text-dim: #666a70;
    --text-faint: #a5a5ad;

    /* brand + action colours (mockup palette) */
    --accent: #7b2ff2;          /* deep purple for text/active */
    --accent-lt: #b27bfb;       /* brand purple */
    --accent-bg: #f0e6fd;
    --accent-soft: rgba(178, 123, 251, 0.14);
    --coral: #fe5c73;           /* destructive */
    --coral-bg: #fde8ec;
    --mint: #16dbcc;            /* confirm / pay */
    --mint-dk: #0ca678;
    --mint-bg: #e4fbf5;
    --ink-dk: #1c1c20;          /* dark chips (status, telemetry) */

    /* semantics */
    --ok: #0ca678;
    --warn: #d9a406;
    --danger: #fe5c73;

    /* geometry */
    --radius: 12px;
    --radius-sm: 8px;
    --tap: 48px;
    --font-scale: 1;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 12px 34px rgba(30, 20, 60, 0.14);
}

/* accessibility preferences (Settings → Branding & accessibility) */
[data-contrast="high"] {
    --text-dim: #3b3e42;
    --text-faint: #6b6e73;
    --border: #b9b9c2;
    --accent: #5b02c7;
}
[data-textsize="large"] { --font-scale: 1.16; --tap: 58px; }

html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Chakra Petch", ui-sans-serif, system-ui, sans-serif;
    font-size: calc(14.5px * var(--font-scale));
    line-height: 1.5;
}

h1, h2, h3, h4, .font-display {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    letter-spacing: -0.01em;
}

.app-root { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ------------------------------------------------------------------ focus */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--accent-lt); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------ scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #e0e0e6; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* -------------------------------------------------------------- utilities */
.surface   { background: var(--surface);   border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.surface-2 { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.text-dim   { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.accent     { color: var(--accent); }
.tap { min-height: var(--tap); min-width: var(--tap); }

/* buttons ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--tap);
    padding: 0 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: #333;
    font: inherit; font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 80ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent-lt); color: var(--accent); background: var(--accent-bg); }
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent-lt); border-color: var(--accent-lt); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.mint { background: var(--mint); border-color: var(--mint); color: #fff; }
.btn.mint:hover { filter: brightness(1.05); color: #fff; background: var(--mint); border-color: var(--mint); }
.btn.coral { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.coral:hover { filter: brightness(1.05); color: #fff; background: var(--coral); border-color: var(--coral); }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn.danger { background: transparent; border-color: var(--coral); color: var(--coral); }
.btn.danger:hover { background: var(--coral-bg); color: var(--coral); border-color: var(--coral); }
.btn.big { min-height: calc(var(--tap) + 10px); font-size: 1.05em; border-radius: var(--radius-sm); font-weight: 700; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }

/* soft sidebar buttons (customer panel) */
.sb-btn {
    width: 100%; border: none; border-radius: 6px;
    background: #efeff2; color: #333;
    min-height: calc(var(--tap) - 8px);
    padding: 8px 10px; font: inherit; font-weight: 500; font-size: 0.92em;
    cursor: pointer; text-align: center;
}
.sb-btn:hover { background: #e6e6ea; }

/* sidebar quick-action links */
.sb-link {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 9px 8px;
    border: none; border-left: 3px solid transparent; border-radius: 6px;
    background: transparent; color: #7b7f88;
    font: inherit; font-size: 0.92em; text-align: left; cursor: pointer;
}
.sb-link:hover { background: var(--surface-3); color: var(--text); }
.sb-link.active { background: var(--accent-bg); border-left-color: var(--accent-lt); color: var(--accent); font-weight: 600; }

/* tiles (product shelf / tender) ---------------------------------------- */
.tile {
    display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
    min-height: calc(var(--tap) * 1.8);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font: inherit; text-align: left;
    cursor: pointer;
    position: relative;
    transition: transform 80ms ease, border-color 120ms ease, background 120ms ease;
}
.tile:hover { border-color: var(--accent-lt); }
.tile { overflow: hidden; }
.tile .t-icon { color: var(--text-faint); display: inline-flex; }
.tile:hover .t-icon { color: var(--accent); }
.tile .t-name {
    font-weight: 600; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; min-height: 2.6em;
}
.tile .t-variant {
    color: var(--text-dim); font-size: 0.85em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .t-price { white-space: nowrap; padding-right: 30px; }
.tile:active { transform: scale(0.98); }
.tile.added { border-color: var(--mint); background: var(--mint-bg); }
.tile .plus {
    position: absolute; right: 10px; bottom: 10px;
    width: 22px; height: 22px; border-radius: 999px;
    background: var(--accent-bg); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9em;
}
.tile.added .plus { background: var(--mint); color: #fff; }

/* category pills --------------------------------------------------------- */
.pill {
    border: 1px solid var(--border); background: var(--surface);
    border-radius: 999px; padding: 8px 16px; min-height: 40px;
    font: inherit; font-size: 0.92em; color: #666; font-weight: 500; cursor: pointer;
}
.pill:hover { border-color: var(--accent-lt); color: var(--accent); }
.pill.active { background: var(--accent-bg); border-color: var(--accent-lt); color: var(--accent); font-weight: 700; }

/* badges ---------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 0.76em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge.ok     { background: var(--mint-bg); color: var(--mint-dk); }
.badge.warn   { background: #fdf5dc; color: var(--warn); }
.badge.danger { background: var(--coral-bg); color: var(--coral); }
.badge.accent { background: var(--accent-bg); color: var(--accent); }
.badge.dim    { background: var(--surface-3); color: var(--text-dim); }
.badge.dark   { background: var(--ink-dk); color: #fff; }

/* line cards ------------------------------------------------------------- */
.line-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    animation: pop 200ms ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.line-ico {
    border: 1px solid var(--border); background: var(--surface);
    border-radius: 6px; width: 34px; height: 34px;
    cursor: pointer; color: #9a9aa2; font: inherit; font-size: 0.85em;
    display: inline-flex; align-items: center; justify-content: center;
}
.line-ico:hover { color: var(--accent); border-color: var(--accent-lt); }
.stepper {
    display: inline-flex; align-items: center; gap: 4px;
    border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}
.stepper button {
    border: none; background: none; cursor: pointer; color: #555;
    font: inherit; font-size: 1.1em; font-weight: 700;
    min-width: 34px; min-height: 34px;
}
.stepper button:hover { color: var(--accent); }

/* copilot --------------------------------------------------------------- */
.copilot-card {
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-lt);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px;
    animation: pop 240ms ease;
    font-size: 0.95em;
}
.copilot-card.warn { border-left-color: var(--coral); }
.copilot-card.success { border-left-color: var(--mint); }
.copilot-card .sev { font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 800; color: var(--accent); }
.copilot-card.warn .sev { color: var(--coral); }
.copilot-card.success .sev { color: var(--mint-dk); }
.copilot-card .why-box {
    font-size: 0.86em; color: #777; background: #f6f4fb;
    border-radius: 6px; padding: 8px 10px; line-height: 1.5;
}
.cop-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--mint); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* keypad ----------------------------------------------------------------- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad .btn { min-height: calc(var(--tap) + 6px); font-size: 1.25em; font-weight: 700; }

/* cash payment ------------------------------------------------------------ */
.coin {
    width: 88px; height: 88px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    font: inherit; font-size: 0.95em; font-weight: 600; color: #333; cursor: pointer;
}
.coin:hover { border-color: var(--mint); color: var(--mint-dk); }
.note {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    padding: 14px; min-height: var(--tap);
    font: inherit; font-size: 0.98em; font-weight: 600; color: #333;
    text-align: center; cursor: pointer;
}
.note:hover { border-color: var(--mint); color: var(--mint-dk); }

/* screen transitions ------------------------------------------------------ */
.screen-enter { animation: screen-in 200ms ease; }
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* toast -------------------------------------------------------------------- */
#toast-root {
    position: fixed; top: 72px; right: 20px;
    display: flex; flex-direction: column; gap: 10px; z-index: 90;
    pointer-events: none; align-items: flex-end;
}
.toast {
    pointer-events: auto;
    background: var(--ink-dk); color: #fff;
    border-radius: var(--radius-sm);
    padding: 12px 18px; font-weight: 600; font-size: 0.94em;
    box-shadow: var(--shadow-md);
    animation: toast-in 200ms ease;
    display: flex; gap: 10px; align-items: center;
}
.toast.ok { border-left: 4px solid var(--mint); }
.toast.warn { border-left: 4px solid #f0d867; }
.toast.danger { border-left: 4px solid var(--coral); }
.toast.accent { border-left: 4px solid var(--accent-lt); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* modal ---------------------------------------------------------------------- */
#modal-root:not(:empty) {
    position: fixed; inset: 0; z-index: 80;
    display: flex; align-items: center; justify-content: center;
    background: rgba(20, 20, 25, 0.5);
    animation: toast-in 160ms ease;
}
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 24px;
    width: min(540px, calc(100vw - 40px));
    max-height: calc(100vh - 80px); overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.modal input.field, .field {
    width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 14px; font: inherit; outline: none; background: var(--surface);
    box-sizing: border-box;
}
.field:focus { border-color: var(--accent-lt); }

/* workflow state pills (approval) */
.wf { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.wf span {
    font-size: 0.62em; text-transform: uppercase; padding: 4px 8px;
    border-radius: 999px; background: var(--surface-3); color: #b5b5bc; font-weight: 700;
}
.wf span.done { background: var(--mint-bg); color: var(--mint-dk); }
.wf span.cur  { background: var(--coral-bg); color: var(--coral); }

/* omnibox ---------------------------------------------------------------------- */
.omnibox {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-3); border: 1px solid transparent;
    border-radius: 999px; padding: 0 18px;
    min-height: var(--tap);
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.omnibox:focus-within { background: var(--surface); border-color: var(--accent-lt); box-shadow: 0 0 0 3px var(--accent-soft); }
.omnibox input {
    flex: 1; background: transparent; border: 0; color: var(--text);
    font: inherit; font-size: 1em; min-height: calc(var(--tap) - 6px);
}
.omnibox input:focus { outline: none; }
.omnibox input::placeholder { color: var(--text-faint); }
.scan-chip {
    font-size: 0.72em; color: var(--text-faint); border: 1px solid #dfdfe4;
    border-radius: 5px; padding: 2px 8px; white-space: nowrap;
}

/* top bar --------------------------------------------------------------------- */
.topbar {
    height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 16px; gap: 12px; flex-shrink: 0;
}
.mode-switch { display: flex; gap: 3px; background: var(--surface-3); border-radius: 999px; padding: 3px; }
.mode-btn {
    border: none; background: transparent; border-radius: 999px;
    padding: 7px 14px; font: inherit; font-size: 0.8em; cursor: pointer;
    color: #777; font-weight: 600; min-height: 36px;
}
.mode-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.tr-ico {
    width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: #555; position: relative; background: var(--surface);
    font: inherit; font-size: 0.95em;
}
.tr-ico:hover { border-color: var(--accent-lt); color: var(--accent); }
.tr-ico .dot { position: absolute; top: 3px; right: 4px; width: 8px; height: 8px; border-radius: 999px; background: var(--mint); }
.avatar {
    width: 38px; height: 38px; border-radius: 999px;
    background: linear-gradient(135deg, #b27bfb, #16dbcc);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95em; border: none; cursor: pointer; font-family: inherit;
}

/* day-ops dropdown -------------------------------------------------------------- */
.dots-panel {
    position: fixed; top: 66px; right: 14px; width: 280px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    z-index: 70; display: flex; flex-direction: column; padding: 8px;
    animation: toast-in 150ms ease;
}
.dots-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 12px; border-radius: 8px; font-size: 0.94em;
    cursor: pointer; color: #333; border: none; background: transparent;
    font-family: inherit; width: 100%; text-align: left; min-height: 44px;
}
.dots-item span.ic { color: #b5b5bc; }
.dots-item:hover { background: var(--accent-bg); color: var(--accent); }
.dots-item.logout { color: var(--coral); }
.dots-status {
    background: var(--ink-dk); color: #fff; border-radius: 999px;
    padding: 10px 14px; font-size: 0.82em; margin: 8px 4px 3px;
    display: flex; gap: 8px; align-items: center; font-weight: 600;
}
.dots-status i { width: 9px; height: 9px; border-radius: 999px; background: #22c55e; flex-shrink: 0; }

/* kiosk attract screen ----------------------------------------------------------- */
.kiosk-attract {
    background:
        radial-gradient(1200px 600px at 20% 10%, rgba(178, 123, 251, 0.35), transparent 55%),
        radial-gradient(900px 500px at 85% 85%, rgba(22, 219, 204, 0.16), transparent 60%),
        #282727;
}
.kiosk-attract .pulse { animation: attract-pulse 2.4s ease-in-out infinite; }
@keyframes attract-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.03); opacity: 0.85; } }

/* login ---------------------------------------------------------------------------- */
.login-bg { background: linear-gradient(160deg, #fafafc 0%, rgba(240, 230, 253, 0.27) 55%, rgba(228, 251, 245, 0.27) 100%); }
.login-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-md); overflow: hidden;
}
.info-tile { border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 8px; }
.spark i { flex: 1; background: var(--accent-bg); border-radius: 2px 2px 0 0; }
.spark i.hi { background: var(--accent-lt); }

/* envelope inspector ---------------------------------------------------------------- */
.inspector {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 90vw); z-index: 75;
    background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex; flex-direction: column;
    animation: inspector-in 200ms ease;
}
@keyframes inspector-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.inspector pre {
    font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word;
    background: var(--ink-dk); color: #9be8dc; border: none;
    border-radius: var(--radius-sm); padding: 12px; margin: 0;
}

/* self-serve BYOD phone frame ------------------------------------------------------- */
.phone-frame {
    width: min(390px, 94vw); height: min(760px, calc(100vh - 170px));
    background: #1c1c20; border-radius: 38px; padding: 10px;
    box-shadow: 0 24px 70px rgba(30, 20, 60, 0.28);
    position: relative; display: flex;
}
.phone-notch {
    position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
    width: 110px; height: 24px; background: #1c1c20; border-radius: 999px; z-index: 5;
}
.phone-screen {
    flex: 1; background: var(--bg-soft); border-radius: 30px; overflow: hidden;
    display: flex; flex-direction: column; padding-top: 34px;
}
.scan-cta {
    display: flex; align-items: center; gap: 14px; justify-content: center;
    background: var(--accent-lt); color: #fff; border: none;
    border-radius: var(--radius); padding: 16px;
    font: inherit; cursor: pointer; min-height: 64px;
    box-shadow: 0 6px 18px rgba(178, 123, 251, 0.35);
}
.scan-cta:hover { filter: brightness(1.05); }
.scan-cta:active { transform: scale(0.985); }
.wallet-pay {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 52px;
    background: #1c1c20; color: #fff; border: none; border-radius: 999px;
    font: inherit; font-weight: 700; cursor: pointer;
}
.wallet-pay:disabled { opacity: 0.4; cursor: not-allowed; }
.wallet-pay:not(:disabled):active { transform: scale(0.985); }

/* simulated camera viewfinder */
.scan-finder {
    position: relative; height: 170px; border-radius: var(--radius-sm);
    background:
        repeating-linear-gradient(90deg, #2a2a30 0 3px, #1c1c20 3px 8px);
    overflow: hidden;
}
.scan-finder.found { outline: 3px solid var(--mint); }
.scan-line {
    position: absolute; left: 8%; right: 8%; height: 2px;
    background: var(--mint); box-shadow: 0 0 12px var(--mint);
    animation: scanline 1.4s ease-in-out infinite;
}
@keyframes scanline { 0%, 100% { top: 18%; } 50% { top: 78%; } }
.scan-corner { position: absolute; width: 22px; height: 22px; border: 3px solid rgba(255, 255, 255, 0.85); }
.scan-corner.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.scan-corner.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.scan-corner.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.scan-corner.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

/* mobile: the phone experiences go frameless (they ARE the phone) */
@media (max-width: 560px) {
    .phone-caption { display: none !important; }
    .phone-frame {
        width: 100%; height: 100%; min-height: 0; flex: 1;
        background: transparent; border-radius: 0; padding: 0; box-shadow: none;
    }
    .phone-notch { display: none; }
    .phone-screen { border-radius: 0; padding-top: 0; }
    .topbar { padding: 0 8px; gap: 8px; }
    .modal { padding: 16px; }
    .coin { width: 68px; height: 68px; }
}

/* reduce motion ------------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
