/* Easy mode stylesheet — see easy-mode-shell.js for behavior.
 * Owned by the easy-mode CSS + shell agent. Loaded unconditionally; all
 * rules MUST be scoped under .easy-mode-active or .easy-page so they never
 * leak into the standard app chrome.
 *
 * Designed for tradespeople in gloves/sunlight on a phone. Hard rules:
 *   - Every tappable thing is at least 44x44 CSS px (Apple HIG).
 *   - Status is communicated by color AND a short word, never hue alone.
 *   - Brand stays Operaite purple #534AB7 — only the UX pattern is borrowed
 *     from Jobber's mobile app.
 */

/* ── Tokens (scoped to easy mode) ───────────────────────────────────────── */
body.easy-mode-active {
  /* Palette */
  --easy-primary: #534AB7;          /* Operaite purple */
  --easy-primary-ink: #ffffff;
  --easy-primary-soft: #ece9fb;     /* tinted surface for selected/hover */
  --easy-primary-border: #d4d0f5;
  --easy-bg: #F5F6F7;               /* secondary surface (scroll body) */
  --easy-surface: #FFFFFF;          /* card / topbar / tabbar */
  --easy-text: #1A1A1A;             /* primary text */
  --easy-text-2: #6B7280;           /* secondary text + inactive tab */
  --easy-hairline: #E6E7E9;         /* 1px dividers */
  --easy-good: #1FB85C;             /* green status */
  --easy-warn: #F5A623;             /* amber status */
  --easy-bad:  #E5484D;             /* red status */
  --easy-neutral: #6B7280;

  /* Shape */
  --easy-radius: 14px;
  --easy-radius-sm: 10px;
  --easy-radius-pill: 999px;
  --easy-shadow: 0 1px 2px rgba(15,15,25,0.05), 0 4px 12px rgba(15,15,25,0.04);
  --easy-shadow-tabbar: 0 -1px 0 var(--easy-hairline), 0 -4px 14px rgba(15,15,25,0.04);

  /* Sizing */
  --easy-topbar-h: 56px;
  --easy-tabbar-h: 64px;
  --easy-tap: 48px;                 /* default tap target (>44px floor) */
  --easy-tap-lg: 52px;              /* primary CTA height */
  --easy-fab-size: 56px;

  /* Typography */
  --easy-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, "Helvetica Neue", Arial, sans-serif;
}

/* ── Body / page reset while easy mode is on ────────────────────────────── */
body.easy-mode-active {
  background: var(--easy-bg);
  color: var(--easy-text);
  font-family: var(--easy-font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* The three injected screen containers act as the scroll body */
body.easy-mode-active .page.easy-page {
  display: none;
  background: var(--easy-bg);
  color: var(--easy-text);
  min-height: 100dvh;
  padding: calc(var(--easy-topbar-h) + env(safe-area-inset-top, 0px))
           0
           calc(var(--easy-tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  box-sizing: border-box;
}
body.easy-mode-active .page.easy-page.active { display: block; }

/* ── Easy shell wrapper (top bar + bottom tab bar) ──────────────────────── */
#easy-shell {
  font-family: var(--easy-font);
  color: var(--easy-text);
}

/* Top bar ----------------------------------------------------------------- */
.easy-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--easy-topbar-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  /* Total visible height grows by the inset; the flex row below still uses
     var(--easy-topbar-h). The page padding-top accounts for this. */
  background: var(--easy-surface);
  border-bottom: 1px solid var(--easy-hairline);
  box-sizing: content-box;
}
.easy-topbar-brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--easy-primary);
  user-select: none;
}
.easy-topbar-brand span { color: var(--easy-text); font-weight: 700; }
.easy-topbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  color: var(--easy-text);
  letter-spacing: -0.005em;
  /* Single-line truncate so it never breaks the bar height */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.easy-topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: var(--easy-radius-pill);
  background: var(--easy-primary-soft);
  color: var(--easy-primary);
  border: 1px solid var(--easy-primary-border);
  font: 600 13px/1 var(--easy-font);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.easy-topbar-action:active { background: #ddd8f6; }

/* Bottom tab bar ---------------------------------------------------------- */
.easy-tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 950;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--easy-surface);
  box-shadow: var(--easy-shadow-tabbar);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.easy-tab {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  margin: 0;
  padding: 8px 4px 6px;
  min-height: var(--easy-tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--easy-text-2);
  font: 600 11px/1.2 var(--easy-font);
  cursor: pointer;
  position: relative;
}
.easy-tab svg { width: 24px; height: 24px; display: block; }
.easy-tab .easy-tab-label { letter-spacing: 0.01em; }
.easy-tab[aria-selected="true"] { color: var(--easy-primary); }
.easy-tab[aria-selected="true"]::before {
  /* Subtle 2px top accent for the active tab — works alongside the label
     color so it isn't hue-only. */
  content: "";
  position: absolute;
  top: 0; left: 22%; right: 22%;
  height: 2px;
  background: var(--easy-primary);
  border-radius: 0 0 2px 2px;
}
.easy-tab:active { background: var(--easy-primary-soft); }

/* ── Reusable building blocks for the view agents ───────────────────────── */

/* Main content wrapper a view file can put inside its #page-easy-* div.
   Pages already have padding for the bars; this is just inner gutter. */
.easy-main {
  display: block;
  width: 100%;
  max-width: 720px;        /* readable cap if forced on at desktop widths */
  margin: 0 auto;
  padding: 16px 16px 24px;
  box-sizing: border-box;
  min-height: 100dvh;
}

/* Buttons ----------------------------------------------------------------- */
.easy-btn-primary,
.easy-btn-secondary,
.easy-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--easy-tap-lg);
  padding: 0 18px;
  border-radius: 12px;
  font: 600 16px/1 var(--easy-font);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid transparent;
  text-decoration: none;
  user-select: none;
  transition: transform 0.05s ease;
}
.easy-btn-primary {
  background: var(--easy-primary);
  color: var(--easy-primary-ink);
}
.easy-btn-primary:active { background: #433aa0; transform: scale(0.99); }
.easy-btn-secondary {
  background: var(--easy-surface);
  color: var(--easy-primary);
  border-color: var(--easy-primary-border);
}
.easy-btn-secondary:active { background: var(--easy-primary-soft); }
.easy-btn-ghost {
  background: transparent;
  color: var(--easy-text);
  border-color: var(--easy-hairline);
}
.easy-btn-ghost:active { background: #eef0f2; }
.easy-btn-primary[disabled],
.easy-btn-secondary[disabled],
.easy-btn-ghost[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Floating action button (bottom-right above the tab bar) */
.easy-fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--easy-tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  width: var(--easy-fab-size);
  height: var(--easy-fab-size);
  border-radius: 50%;
  background: var(--easy-primary);
  color: var(--easy-primary-ink);
  border: 0;
  box-shadow: 0 6px 18px rgba(83,74,183,0.35), 0 2px 4px rgba(15,15,25,0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 940;
  -webkit-appearance: none;
  appearance: none;
}
.easy-fab svg { width: 26px; height: 26px; }
.easy-fab:active { transform: scale(0.96); background: #433aa0; }

/* Cards ------------------------------------------------------------------- */
.easy-card {
  background: var(--easy-surface);
  border-radius: var(--easy-radius);
  box-shadow: var(--easy-shadow);
  padding: 16px;
  margin: 0 0 12px;
  box-sizing: border-box;
}
.easy-card + .easy-card { margin-top: 0; }

/* List rows (used inside .easy-card or stacked directly) ------------------ */
.easy-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  background: var(--easy-surface);
  border-bottom: 1px solid var(--easy-hairline);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.easy-list-row:last-child { border-bottom: 0; }
.easy-list-row:active { background: #f1f2f4; }
.easy-list-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.easy-list-row-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--easy-text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.easy-list-row-sub {
  font-size: 13px;
  color: var(--easy-text-2);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.easy-list-row-meta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--easy-text-2);
}
.easy-list-row-meta svg { width: 22px; height: 22px; }

/* Group list rows inside one rounded card */
.easy-list {
  background: var(--easy-surface);
  border-radius: var(--easy-radius);
  box-shadow: var(--easy-shadow);
  overflow: hidden;
  margin: 0 0 12px;
}

/* Status pills — color AND a short word, never hue alone ----------------- */
.easy-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--easy-radius-pill);
  font: 600 12px/1.2 var(--easy-font);
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.easy-status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
  flex-shrink: 0;
}
.easy-status-pill.good    { color: #0f7a3a; background: #e3f6ea; border-color: #c5ecd3; }
.easy-status-pill.warn    { color: #8a5300; background: #fdefd4; border-color: #f6dca5; }
.easy-status-pill.bad     { color: #a8181c; background: #fde4e5; border-color: #f6c2c4; }
.easy-status-pill.neutral { color: #3f4753; background: #ecedf0; border-color: #dcdee2; }

/* Typography helpers ----------------------------------------------------- */
.easy-page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--easy-text);
  margin: 4px 0 14px;
}
.easy-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--easy-text-2);
  margin: 18px 4px 8px;
}

/* Empty state ------------------------------------------------------------ */
.easy-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 24px;
  background: var(--easy-surface);
  border-radius: var(--easy-radius);
  box-shadow: var(--easy-shadow);
  color: var(--easy-text-2);
  gap: 10px;
}
.easy-empty-icon {
  width: 56px; height: 56px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--easy-primary-soft);
  color: var(--easy-primary);
  margin-bottom: 4px;
}
.easy-empty-icon svg { width: 28px; height: 28px; }
.easy-empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--easy-text);
}
.easy-empty-body {
  font-size: 14px;
  line-height: 1.45;
  max-width: 320px;
}
.easy-empty .easy-btn-primary,
.easy-empty .easy-btn-secondary { max-width: 320px; margin-top: 8px; }

/* Form bits (lightweight; view agents can extend) ------------------------ */
.easy-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
}
.easy-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--easy-text-2);
  letter-spacing: 0.02em;
}
.easy-field-input,
.easy-field-textarea,
.easy-field-select {
  width: 100%;
  min-height: var(--easy-tap);
  padding: 12px 14px;
  border-radius: var(--easy-radius-sm);
  border: 1px solid var(--easy-hairline);
  background: var(--easy-surface);
  font: 500 16px/1.3 var(--easy-font);
  color: var(--easy-text);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.easy-field-textarea { min-height: 96px; resize: vertical; }
.easy-field-input:focus,
.easy-field-textarea:focus,
.easy-field-select:focus {
  outline: none;
  border-color: var(--easy-primary);
  box-shadow: 0 0 0 3px rgba(83,74,183,0.18);
}

/* Reduced-motion respect ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  body.easy-mode-active * { transition: none !important; }
}
