/* =====================================================================================
   SlotWise theme layer. Loaded after ui.css (and before app.css in the mobile app).
   Mobile first: every rule below works on a 360px phone first and widens from there.
   Adds: onboarding pages, accessible focus, comfortable touch targets, safe areas, reduced motion.
   ===================================================================================== */

:root {
  --sw-radius-card: 16px;
  --sw-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --sw-border: #E2E8F0;
  --sw-ink: #0F172A;
  --sw-muted: #475569;          /* 7.6:1 on white: passes AA for body text */
  --sw-accent: #556B2F;
  --sw-accent-soft: #F1F5E4;
  --sw-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--sw-font); color: var(--sw-ink); -webkit-tap-highlight-color: transparent; }

/* ---------- Keyboard focus: always visible, never removed ---------------------------- */
:focus-visible { outline: 3px solid #556B2F; outline-offset: 2px; border-radius: 4px; }
.form-control:focus-visible, .form-select:focus-visible { outline: none; }   /* these draw their own ring */

/* ---------- Skip link ----------------------------------------------------------------- */
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 2000; background: #fff; color: #435723; padding: 0.75rem 1rem; font-weight: 600; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

/* ---------- Touch targets and mobile typing ------------------------------------------ */
@media (max-width: 767.98px) {
  .btn, .form-control, .form-select, .nav-link { min-height: 44px; }
  /* 16px inputs stop iOS from zooming the page on focus. */
  .form-control, .form-select, textarea { font-size: 16px; }
  main, .container-fluid { padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
}

/* ---------- Onboarding (business sign-up) -------------------------------------------- */
.onboard { background: linear-gradient(180deg, #F1F5E4 0%, #F8FAFC 320px); min-height: 100vh; padding: 24px 0 48px; }
.onboard-wrap { width: 100%; max-width: 780px; margin: 0 auto; padding: 0 16px; }
.onboard-head { text-align: center; margin-bottom: 20px; }
.onboard-form { display: grid; gap: 16px; }
.onboard-card { background: #fff; border: 1px solid var(--sw-border); border-radius: var(--sw-radius-card); box-shadow: var(--sw-shadow-card); padding: 20px; }
.onboard-h { font-size: 1.0625rem; font-weight: 700; margin: 0 0 16px; color: var(--sw-ink); }
.onboard-card .form-group { margin-bottom: 16px; }
.onboard-card .form-label, .onboard-card legend.form-label { display: block; font-weight: 600; font-size: 0.875rem; color: var(--sw-ink); margin-bottom: 6px; padding: 0; }
.onboard-card .form-text { color: var(--sw-muted); font-size: 0.8125rem; }
.onboard-card .input-group-text { background: #F8FAFC; color: var(--sw-muted); font-size: 0.8125rem; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }

/* Business-type tiles: real radio inputs (keyboard and screen reader friendly), styled as cards. */
.type-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 576px) { .type-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 992px) { .type-grid { grid-template-columns: repeat(3, 1fr); } }
.type-tile { position: relative; }
.type-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.type-label {
  display: grid; grid-template-columns: 40px 1fr; grid-template-areas: "icon name" "icon desc"; column-gap: 12px; row-gap: 2px; align-items: center;
  height: 100%; min-height: 64px; padding: 12px 14px; cursor: pointer; background: #fff; border: 1.5px solid var(--sw-border); border-radius: 12px;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.type-label:hover { border-color: #B7C98A; background: #FAFCF3; }
.type-icon { grid-area: icon; width: 40px; height: 40px; display: grid; place-items: center; font-size: 1.25rem; color: var(--sw-accent); background: var(--sw-accent-soft); border-radius: 10px; }
.type-name { grid-area: name; font-weight: 650; font-size: 0.9375rem; line-height: 1.2; }
.type-desc { grid-area: desc; font-size: 0.8125rem; color: var(--sw-muted); line-height: 1.3; }
.type-input:checked + .type-label { border-color: var(--sw-accent); background: var(--sw-accent-soft); box-shadow: 0 0 0 3px rgba(85, 107, 47, 0.15); }
.type-input:focus-visible + .type-label { outline: 3px solid #556B2F; outline-offset: 2px; }

/* The onboarding pages are full-screen forms: no navbar offset needed, and the app shell keeps its own padding. */
html:not(.app-mode) body > main:has(> .onboard) { max-width: none; padding: 0; }

/* ---------- Reduced motion ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Secondary text: solid colours, never faded with opacity (opacity lowers contrast on tinted backgrounds) ---- */
.page-subtitle { color: var(--sw-muted); opacity: 1; }

/* ---------- CUSTOM FIELDS: question blocks, errors next to fields, admin list ----------------------------- */
.custom-fields .custom-field .invalid-feedback { color: #B91C1C; font-weight: 500; font-size: 0.875rem; }   /* 6.5:1 on white */
.custom-fields .form-text { color: var(--sw-muted); }
.custom-fields legend { color: var(--sw-ink); }
.custom-fields-table td .btn[disabled] { opacity: 0.35; }
.cf-preview .card-body { background: #FAFCF3; }
@media (max-width: 767.98px) { .custom-fields-table td .btn { min-width: 44px; } }

/* ---------- Notifications: bell, "New" mark and the Notifications page ---------- */
.notif-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; color: inherit; text-decoration: none; border-radius: 10px; }
.notif-bell .bi { font-size: 1.2rem; }
.notif-bell:hover { background: rgba(85, 107, 47, .12); }
.notif-badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #B42318; color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.notif-badge[hidden] { display: none; }
.badge-new { background: #556B2F; color: #fff; font-weight: 600; letter-spacing: .02em; }
.badge-new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #B42318; margin-left: 4px; vertical-align: middle; }
.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.notif-item { display: grid; grid-template-columns: auto 1fr; gap: .75rem; padding: 1rem; border: 1px solid var(--bs-border-color, #dfe3d6); border-radius: 12px; background: #fff; }
.notif-item.is-unread { border-left: 4px solid #556B2F; background: #F7F9F1; }
.notif-icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: #E3EBCB; color: #3F5120; font-size: 1.1rem; }
.notif-icon.kind-cancel, .notif-icon.kind-noshow { background: #FDE8E6; color: #912018; }
.notif-icon.kind-move { background: #FEF3C7; color: #92400E; }
.notif-title { font-weight: 600; margin: 0; }
.notif-meta { color: #5b6350; font-size: .875rem; margin: .15rem 0 0; }
.notif-issue { white-space: pre-line; margin: .5rem 0 0; padding: .5rem .75rem; background: #fff; border: 1px dashed #c9d1b4; border-radius: 8px; font-size: .9rem; overflow-wrap: anywhere; }
.notif-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.notif-item .notif-actions .btn { min-height: 44px; display: inline-flex; align-items: center; }
.notif-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.notif-tabs .btn { min-height: 44px; }
.notif-source { background: #EEF2E0; color: #3F5120; border: 1px solid #c9d1b4; font-weight: 600; }


/* ---------- UI GUIDE (docs/UI_GUIDE.md): olive tokens, shared form look, responsive tables ----------------- */
:root {
  --sw-primary: #556B2F;
  --sw-primary-dark: #435723;
  --sw-primary-soft: #F1F5E4;
  --sw-danger-text: #B91C1C;
  --sw-space-1: 4px; --sw-space-2: 8px; --sw-space-3: 12px; --sw-space-4: 16px; --sw-space-5: 24px;
}
.form-label { font-weight: 600; font-size: 0.875rem; color: var(--sw-ink); margin-bottom: 0.375rem; }
.form-text, .field-hint { color: var(--sw-muted); font-size: 0.8125rem; }
.invalid-feedback, .text-danger.field-validation-error, .field-validation-error { color: var(--sw-danger-text); font-size: 0.8125rem; font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 575.98px) {
  /* Forms: one column on phones, so labels and fields line up. */
  form .row > [class*="col-md-"], form .row > [class*="col-sm-"], form .row > [class*="col-lg-"] { flex: 0 0 100%; max-width: 100%; width: 100%; }
  /* Button row: full-width buttons, primary first. */
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
@media (max-width: 767.98px) {
  .btn.btn-sm, .btn.btn-ghost, .btn-sm, .btn-ghost { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  /* Platform section links: one scrolling strip instead of three wrapped rows. */
  .sw-subnav { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .sw-subnav .btn { white-space: nowrap; flex: 0 0 auto; }
  /* Website tables become stacked cards when a cell has a data-label. */
  table.table-stack thead { display: none; }
  table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td { display: block; width: 100%; }
  table.table-stack tr { margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--sw-border); border-radius: 12px; background: #fff; }
  table.table-stack td { border: 0; padding: 0.25rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--sw-muted); text-align: left; }
}
@media (max-width: 767.98px) {
  .navbar-toggler, .password-toggle { min-width: 44px; min-height: 44px; }
}

@media (max-width: 767.98px) { .pagination .page-link { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; } }
