/* ============================================================
   Test Bakery App — polish layer on top of Tailwind CDN
   Phone-shaped web app. Indigo #4F46E5 primary, light theme.
   ============================================================ */

:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-soft: #EEF2FF;
  --ink: #111827;
  --ink-soft: #6B7280;
  --line: #E5E7EB;
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --shell-w: 430px;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: #E5E7EB;
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Phone shell — centers content and caps width */
.shell {
  max-width: var(--shell-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 60px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}

/* scroll area sits above the tab bar */
.page {
  flex: 1;
  padding-bottom: 92px;
  overflow-x: hidden;
}

/* ---------- App bars ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
}
.appbar-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.appbar-sub { font-size: 12px; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px;
  border-radius: 14px; padding: 14px 18px;
  border: none; cursor: pointer; transition: transform .06s ease, background .15s ease, opacity .15s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #C7CBDA; color: #fff; cursor: not-allowed; }
.btn-ghost { background: var(--primary-soft); color: var(--primary); }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 11px; width: auto; }
.btn-danger-ghost { background: #FEF2F2; color: var(--danger); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.card-tight { padding: 12px; }
.card-flat { border: 1px solid var(--line); border-radius: 16px; background: #fff; }

/* ---------- Thumbnails ---------- */
.thumb {
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .01em;
  padding: 4px 9px; border-radius: 999px;
}
.pill-open, .pill-ready { background: #DCFCE7; color: #15803D; }
.pill-soon, .pill-progress { background: #FEF3C7; color: #B45309; }
.pill-closed, .pill-cancelled { background: #FEE2E2; color: #B91C1C; }
.pill-new { background: var(--primary-soft); color: var(--primary); }
.pill-completed { background: #F3F4F6; color: #4B5563; }
.pill-info { background: var(--primary-soft); color: var(--primary); }
.pill-warn { background: #FEF3C7; color: #B45309; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 8px;
  background: #F3F4F6; color: #4B5563;
}
.tag-diet { background: #ECFDF5; color: #047857; }
.tag-nut { background: #FEF2F2; color: #B91C1C; }

/* ---------- Segmented control ---------- */
.segment {
  display: flex; background: #EEF0F4; border-radius: 12px; padding: 4px; gap: 4px;
}
.segment button {
  flex: 1; border: none; background: transparent; cursor: pointer;
  font-weight: 600; font-size: 13px; color: var(--ink-soft);
  padding: 9px 8px; border-radius: 9px; transition: all .15s;
}
.segment button.seg-on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  background: #fff; border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; transition: all .15s;
}
.chip.chip-on { background: var(--primary); color: #fff; border-color: var(--primary); }

.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }

/* ---------- Inputs ---------- */
.input, textarea.input, select.input {
  width: 100%; font-size: 15px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border .15s, box-shadow .15s;
  font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-error { border-color: var(--danger); }
.field-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
.field-hint { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }
.field-err { font-size: 12px; color: var(--danger); margin-top: 5px; }

/* ---------- Stepper ---------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { width: 40px; height: 40px; border: none; background: #fff; font-size: 20px; color: var(--primary); cursor: pointer; font-weight: 600; }
.stepper button:disabled { color: #CBD5E1; cursor: not-allowed; }
.stepper .qval { min-width: 34px; text-align: center; font-weight: 700; font-size: 15px; }

/* ---------- Sticky bottom action bar (above tab bar) ---------- */
.actionbar {
  position: fixed; bottom: 72px; left: 0; right: 0;
  max-width: var(--shell-w); margin: 0 auto;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  z-index: 25;
}
/* when a page has no tab bar (subpages), pin action bar to bottom */
.actionbar-bottom { bottom: 0; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: var(--shell-w); margin: 0 auto;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex; z-index: 40;
  padding: 8px 6px 10px;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--ink-soft); font-size: 11px; font-weight: 600;
  padding: 4px 0;
}
.tab-icon { font-size: 20px; position: relative; filter: grayscale(0.4); opacity: 0.7; }
.tab-on { color: var(--primary); }
.tab-on .tab-icon { filter: none; opacity: 1; }
.tab-badge {
  position: absolute; top: -6px; right: -12px;
  background: var(--primary); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 999px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

/* ---------- Skeletons ---------- */
.skel { background: linear-gradient(90deg, #eceef1 25%, #f5f6f8 50%, #eceef1 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; font-size: 14px; font-weight: 600;
  padding: 12px 18px; border-radius: 12px; z-index: 100; opacity: 0; transition: all .3s;
  max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Bottom sheet / modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,0.45); z-index: 60; max-width: 100%; opacity: 0; transition: opacity .2s; }
.sheet-backdrop.on { opacity: 1; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: var(--shell-w); margin: 0 auto;
  background: #fff; border-radius: 22px 22px 0 0; z-index: 61;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s ease;
  max-height: 82vh; overflow-y: auto;
}
.sheet.on { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: #D1D5DB; border-radius: 999px; margin: 0 auto 14px; }

/* ---------- Misc layout helpers ---------- */
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--ink-soft); }
.divider { height: 1px; background: var(--line); margin: 0; border: none; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.truncate-1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-gradient { background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #F3F4F6; border: none; cursor: pointer; font-size: 18px; color: var(--ink); }
.link { color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: none; }
.accent-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px; }
.empty-illus { font-size: 52px; text-align: center; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner-dark { border-color: rgba(79,70,229,0.25); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
