/* ================================================
   Spengil Orders — the customer ordering app (order/index.php)
   Phone-first: pinned header, bottom tabs, big touch targets,
   16px form text (no iPhone zoom), room for the iPhone home bar.
   ================================================ */
:root {
    --dark:      #363231;
    --teal:      #2596be;
    --teal-dark: #1a7a9e;
    --teal-soft: rgba(37,150,190,.10);
    --light:     #f4f6f8;
    --white:     #ffffff;
    --ink:       #2b2827;
    --muted:     #6b7280;
    --line:      #e5e7eb;
    --green:     #15803d;
    --amber:     #b45309;
    --red:       #b91c1c;
    --radius:    14px;
    --tabs-h:    62px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 16px; line-height: 1.45;
    color: var(--ink);
    background: var(--light);
    -webkit-tap-highlight-color: transparent;
}
a { color: var(--teal); }
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a, button, input, label, summary { touch-action: manipulation; }   /* taps respond at once, no double-tap zoom */
:focus-visible { outline: 3px solid rgba(37,150,190,.55); outline-offset: 2px; }

/* ── Header ───────────────────────────────────── */
.oa-top {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    background: var(--white);
    border-bottom: 3px solid var(--teal);
    box-shadow: 0 4px 18px rgba(0,0,0,.06);
}
.oa-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--dark); }
.oa-brand-text { display: flex; flex-direction: column; line-height: 1; }
.oa-brand-text strong { font-family: 'Barlow Condensed', sans-serif; font-size: 1.35rem; font-weight: 800; letter-spacing: .02em; }
.oa-brand-text strong b { color: var(--teal); font-weight: 800; }
.oa-brand-text small { font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.oa-help {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 999px;
    background: #e9f8ef; color: #128c4a; font-weight: 700; font-size: .9rem; text-decoration: none;
}
.oa-help i { font-size: 1.1rem; }

/* ── Main column ──────────────────────────────── */
.oa-main {
    max-width: 640px; margin: 0 auto;
    padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.oa-title { font-family: 'Barlow Condensed', sans-serif; font-size: 1.75rem; font-weight: 800; line-height: 1.1; margin: 4px 0 14px; color: var(--dark); }
.oa-h { font-family: 'Barlow Condensed', sans-serif; font-size: .95rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 20px 0 10px; }
.oa-muted { color: var(--muted); font-size: .9rem; }
.oa-center { text-align: center; }
.oa-note { display: flex; gap: 8px; align-items: flex-start; margin: 18px 0 0; font-size: .88rem; color: var(--muted); }
.oa-note i { color: var(--teal); margin-top: 2px; }
.oa-back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 2px -4px; padding: 6px 4px; font-weight: 600; text-decoration: none; }

/* ── Buttons ──────────────────────────────────── */
.oa-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 22px;
    border: 0; border-radius: 12px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: .01em;
    text-decoration: none; cursor: pointer;
    box-shadow: 0 6px 16px rgba(37,150,190,.28);
}
.oa-btn:disabled { opacity: .65; cursor: default; }
.oa-btn-outline { background: var(--white); color: var(--teal); border: 2px solid var(--teal); box-shadow: none; }
.oa-btn-sm { min-height: 38px; padding: 0 14px; font-size: .9rem; border-radius: 10px; }
.oa-btn-block { display: flex; width: 100%; margin-top: 14px; }
.oa-link { background: none; border: 0; padding: 6px 4px; color: var(--muted); font-weight: 600; cursor: pointer; }

/* ── Search ───────────────────────────────────── */
.oa-search {
    display: flex; align-items: center; gap: 10px;
    padding: 0 6px 0 16px; min-height: 54px;
    background: var(--white); border: 2px solid var(--line); border-radius: 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.04);
}
.oa-search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(37,150,190,.15); }
.oa-search > i { color: var(--teal); font-size: 1.15rem; }
.oa-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 14px 0; }
.oa-search input::-webkit-search-cancel-button { display: none; }
.oa-clear { border: 0; background: none; color: #9ca3af; font-size: 1.2rem; padding: 10px; cursor: pointer; }

/* ── Brands / series ──────────────────────────── */
.oa-brands { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 520px) { .oa-brands { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.oa-brand-card {
    display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
    padding: 18px 10px 14px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    text-decoration: none; color: var(--ink);
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.oa-brand-card:active { transform: scale(.98); }
.oa-brand-card img { height: 40px; width: auto; object-fit: contain; margin-bottom: 4px; }
.oa-brand-initial {
    width: 44px; height: 44px; border-radius: 12px; margin-bottom: 4px;
    display: flex; align-items: center; justify-content: center;
    background: var(--teal-soft); color: var(--teal);
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.5rem; font-weight: 800;
}
.oa-brand-card strong { font-size: 1rem; line-height: 1.2; }
.oa-brand-card small { color: var(--muted); font-size: .8rem; }
.oa-series { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.oa-series-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 15px 16px; min-height: 58px;
    text-decoration: none; color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.oa-series-row:last-child { border-bottom: 0; }
.oa-series-row span { display: flex; flex-direction: column; min-width: 0; }
.oa-series-row small { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oa-series-row i { color: #9ca3af; }

/* ── Part cards ───────────────────────────────── */
.oa-part {
    display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 4px 12px;
    padding: 14px; margin-bottom: 10px;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.oa-thumb {
    grid-row: span 2;
    width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--teal-soft); color: var(--teal); font-size: 1.5rem;
}
.oa-thumb img { width: 100%; height: 100%; object-fit: cover; }
.oa-part-body { min-width: 0; }
.oa-part-name { font-weight: 700; line-height: 1.25; color: var(--dark); }
.oa-part-no { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; color: var(--teal-dark); margin-top: 2px; word-break: break-word; }
.oa-part-meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.oa-part-desc {
    font-size: .86rem; color: #4b5563; margin-top: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.oa-avail { display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.oa-avail-in     { background: #dcfce7; color: var(--green); }
.oa-avail-order  { background: #fef3c7; color: var(--amber); }
.oa-avail-out    { background: #fee2e2; color: var(--red); }
.oa-avail-custom { background: #eef2f7; color: #475569; }
.oa-part-act { grid-column: 2; display: flex; justify-content: flex-end; margin-top: 6px; }
.oa-add {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 42px; padding: 0 18px;
    border: 2px solid var(--teal); border-radius: 12px;
    background: var(--white); color: var(--teal); font-weight: 700; cursor: pointer;
}
.oa-add:active { background: var(--teal-soft); }

/* Quantity stepper */
.oa-step { display: inline-flex; align-items: center; border: 2px solid var(--teal); border-radius: 12px; overflow: hidden; background: var(--white); }
.oa-step button { width: 44px; height: 42px; border: 0; background: var(--teal-soft); color: var(--teal); font-size: 1.05rem; cursor: pointer; }
.oa-step button:active { background: rgba(37,150,190,.22); }
.oa-step span, .oa-step input { min-width: 44px; width: 52px; text-align: center; font-weight: 700; border: 0; background: transparent; font-size: 16px; padding: 0; -moz-appearance: textfield; }
.oa-step input::-webkit-outer-spin-button, .oa-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Cart ─────────────────────────────────────── */
.oa-cart { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.oa-cart-row { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.oa-cart-row:last-child { border-bottom: 0; }
.oa-cart-qty { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.oa-remove { display: inline-flex; align-items: center; gap: 4px; color: var(--red); }
.oa-custom { margin-top: 14px; background: var(--white); border: 1px dashed #cbd5e1; border-radius: var(--radius); }
.oa-custom summary { display: flex; align-items: center; gap: 8px; padding: 14px 16px; font-weight: 700; color: var(--teal); cursor: pointer; list-style: none; }
.oa-custom summary::-webkit-details-marker { display: none; }
.oa-custom-form { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 0 16px 16px; align-items: end; }
.oa-custom-form label:not(.oa-custom-qty) { grid-column: 1 / -1; }   /* part number, description: full width; qty + button share the last row */
.oa-summary { margin-top: 16px; padding: 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.oa-summary p { margin: 6px 0 0; }

/* ── Forms ────────────────────────────────────── */
.oa-fields { display: grid; gap: 12px; }
.oa-field, .oa-custom-form label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; color: var(--dark); }
.oa-field input, .oa-field textarea, .oa-custom-form input {
    width: 100%; font-size: 16px; font-weight: 400;
    padding: 12px 14px; min-height: 48px;
    border: 1.5px solid #d1d5db; border-radius: 12px; background: var(--white);
}
.oa-field textarea { resize: vertical; min-height: 84px; }
.oa-field input:focus, .oa-field textarea:focus, .oa-custom-form input:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(37,150,190,.15); }
.oa-invalid { border-color: var(--red) !important; box-shadow: 0 0 0 4px rgba(185,28,28,.12) !important; }
.oa-req { color: var(--red); }
.oa-check { display: flex; align-items: center; gap: 10px; font-size: .95rem; padding: 4px 0; }
.oa-check input { width: 20px; height: 20px; accent-color: var(--teal); }
.oa-error { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #fee2e2; color: var(--red); font-weight: 600; }

/* Pay now / pay later */
.oa-pay { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.oa-pay-card { position: relative; cursor: pointer; }
.oa-pay-card input { position: absolute; opacity: 0; pointer-events: none; }
.oa-pay-card span {
    display: flex; flex-direction: column; gap: 3px; height: 100%;
    padding: 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--white);
}
.oa-pay-card i { font-size: 1.35rem; color: var(--teal); }
.oa-pay-card input[value="pay_now"] + span i { color: #16a34a; }
.oa-pay-card strong { font-size: 1.02rem; color: var(--dark); }
.oa-pay-card small { font-size: .8rem; color: var(--muted); line-height: 1.35; }
.oa-pay-card em { position: absolute; top: 10px; right: 10px; font-style: normal; font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #16a34a; background: #dcfce7; padding: 2px 7px; border-radius: 999px; }
.oa-pay-card input:checked + span { border-color: var(--teal); background: #f2fafd; box-shadow: 0 0 0 3px rgba(37,150,190,.15); }
.oa-pay-card input:focus-visible + span { outline: 3px solid rgba(37,150,190,.55); outline-offset: 2px; }

/* ── Order sent / my orders ───────────────────── */
.oa-done { text-align: center; padding-top: 18px; }
.oa-done p { margin: 0 0 10px; }
.oa-done-icon {
    width: 76px; height: 76px; margin: 0 auto 10px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #dcfce7; color: var(--green); font-size: 2.6rem;
}
.oa-ref { display: inline-block; margin: 0 0 14px; padding: 6px 14px; border-radius: 999px; background: var(--teal-soft); color: var(--teal-dark); }
.oa-contact { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0 4px; }
.oa-contact .oa-btn { flex: 1 1 140px; padding: 0 14px; white-space: nowrap; }
.oa-order { margin-bottom: 10px; padding: 14px 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.oa-order-head { display: flex; justify-content: space-between; gap: 10px; }
.oa-order-head span { color: var(--muted); font-size: .88rem; }
.oa-order-items { margin: 8px 0 10px; font-size: .92rem; }
.oa-order-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ── Empty / loading / toast ──────────────────── */
.oa-empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.oa-empty > i { display: block; font-size: 2.4rem; color: #9fcbd5; margin-bottom: 8px; }
.oa-empty p { margin: 0 0 14px; }
.oa-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 36px 0; color: var(--muted); }
.oa-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(37,150,190,.25); border-top-color: var(--teal); animation: oa-spin .8s linear infinite; }
.oa-btn .oa-spin { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.oa-spin[hidden] { display: none; }
@keyframes oa-spin { to { transform: rotate(360deg); } }
.oa-toast {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
    bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom));
    padding: 11px 18px; border-radius: 999px;
    background: var(--dark); color: #fff; font-weight: 600; font-size: .92rem;
    box-shadow: 0 10px 28px rgba(0,0,0,.25);
    white-space: nowrap;
}
.oa-toast[hidden] { display: none; }

/* ── Bottom tabs ──────────────────────────────── */
.oa-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; justify-content: center;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--white);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(0,0,0,.06);
}
.oa-tabs a {
    position: relative; flex: 1; max-width: 180px; height: var(--tabs-h);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.oa-tabs a i { font-size: 1.35rem; line-height: 1; }
.oa-tabs a.active { color: var(--teal); }
.oa-tabs a.active::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal); }
.oa-count {
    position: absolute; top: 7px; left: calc(50% + 7px);
    min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
    background: #dc2626; color: #fff; font-size: .7rem; font-weight: 800; line-height: 19px; text-align: center;
}
.oa-count[hidden] { display: none; }

/* ── Install bar (shown by assets/js/portal-app.js) — sits above the tabs ── */
.install-bar {
    position: fixed; left: 12px; right: 12px; z-index: 40;
    bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--teal);
    border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.18);
    animation: oa-rise .35s ease;
}
.install-bar[hidden] { display: none; }
.install-bar img { flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .84rem; line-height: 1.35; }
.install-text > strong:first-child { font-family: 'Barlow Condensed', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--dark); }
.install-text span { color: var(--muted); }
.install-text .bi { color: var(--teal); }
.install-actions { display: flex; flex-direction: column; align-items: stretch; gap: 2px; flex-shrink: 0; }
.install-actions .oa-link { font-size: .82rem; }
.install-bar[data-mode="ios"] [data-for="android"],
.install-bar[data-mode="android"] [data-for="ios"] { display: none; }
@keyframes oa-rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 576px) {
    .install-bar { left: auto; width: 440px; }
    .install-actions { flex-direction: row-reverse; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
    .install-bar, .oa-spin { animation: none; }
}

/* ── "Get the app" screen (order/?get=1 — from the website's banner / QR code) ── */
.oa-sheet {
    position: fixed; inset: 0; z-index: 60;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(31,29,28,.55);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    animation: oa-fade .25s ease;
}
.oa-sheet[hidden] { display: none; }
.oa-sheet-card {
    position: relative; width: 100%; max-width: 480px;
    max-height: calc(100vh - 24px); overflow-y: auto;
    padding: 26px 22px calc(18px + env(safe-area-inset-bottom));
    background: var(--white); border-radius: 22px 22px 0 0;
    text-align: center;
    box-shadow: 0 -12px 40px rgba(0,0,0,.25);
    animation: oa-sheet-up .32s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 576px) {
    .oa-sheet { align-items: center; }
    .oa-sheet-card { border-radius: 22px; padding-bottom: 22px; }
}
.oa-sheet-close { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f1f3f5; color: var(--muted); cursor: pointer; }
.oa-sheet-icon { display: block; margin: 0 auto 10px; filter: drop-shadow(0 8px 18px rgba(37,150,190,.30)); }
.oa-sheet-card h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.6rem; font-weight: 800; line-height: 1.1; margin: 0 0 12px; color: var(--dark); }
.oa-perks { list-style: none; padding: 0; margin: 0 auto 18px; display: inline-flex; flex-direction: column; gap: 6px; text-align: left; font-weight: 600; color: #374151; }
.oa-perks i { color: var(--teal); margin-right: 8px; }
.oa-sheet .oa-btn .oa-spin[hidden], .oa-sheet .oa-btn i[hidden] { display: none; }
.oa-sheet-skip { display: block; margin: 14px auto 0; font-size: .92rem; }
.oa-steps { list-style: none; padding: 0; margin: 0; text-align: left; display: grid; gap: 10px; }
.oa-steps li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #f4f8fa; font-size: .98rem; }
.oa-steps li > span {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--teal); color: #fff; font-weight: 800;
}
.oa-steps li small { display: block; color: var(--muted); font-size: .8rem; }
.oa-steps i { color: var(--teal); }
.oa-get-note { margin: 12px 0 0; text-align: left; font-size: .85rem; }
.oa-get-help { text-align: left; padding: 14px 16px; border-radius: 14px; background: #f4f8fa; }
.oa-get-help p { margin: 0 0 8px; }
.oa-get-help p:last-child { margin-bottom: 0; }
.oa-get-qr { display: block; width: 180px; height: 180px; margin: 0 auto 10px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.oa-get-done { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; border-radius: 14px; background: #dcfce7; color: var(--green); }
.oa-get-done i { font-size: 1.8rem; }
.oa-get-done p { margin: 0; color: #14532d; }
@keyframes oa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes oa-sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .oa-sheet, .oa-sheet-card { animation: none; } }
