/* ==========================================================================
   TABIFLOW V2 — Modals
   --------------------------------------------------------------------------
   File:  styles/components/modals.css
   Scope: All rules scoped to html.tf-v2panel — zero V1 impact.
   Pass:  1 (CSS foundation)

   Components covered:
     1. Empty state          (.empty-state)
     2. Drop-pin card        (.mobile-place-stop / .mobile-place-current)
     3. A46 disclaimer       (#time-estimates-modal / #time-estimates-backdrop)

   NOTE — A46 copy: placeholder text (E1 Draft 1, locked 2026-05-17).
   Lawyer review 2026-05-22. Final text expected Sat/Mon post-meeting.
   Swap is a string replacement in planner.html — no CSS rebuild needed.
   ========================================================================== */


/* ── 1. Empty state ──────────────────────────────────────────────────────── */

html.tf-v2panel .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 480px;
  padding: var(--tf-space-xxl) var(--tf-space-lg);
  text-align: center;
}

html.tf-v2panel .empty-state .empty-mochi {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--tf-mochi-bg);
  border: 2px solid var(--tf-mochi-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: var(--tf-space-xl);
  flex-shrink: 0;
}

html.tf-v2panel .empty-state h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 var(--tf-space-sm);
  color: var(--tf-text-primary);
}

html.tf-v2panel .empty-state p {
  font-size: 14px;
  color: var(--tf-text-secondary);
  max-width: 280px;
  margin: 0 auto var(--tf-space-xl);
  line-height: 1.6;
}

html.tf-v2panel .empty-state .cta {
  background: var(--tf-primary);
  color: var(--tf-primary-ink);
  border: 0;
  border-radius: var(--tf-radius-md);
  padding: var(--tf-space-md) var(--tf-space-xl);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tf-tap-min);
}


/* ── 2. Drop-pin confirmation card (.mobile-place-current surface) ────────── */

html.tf-v2panel .mobile-place-stop {
  background: var(--tf-bg-surface);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-md);
  padding: var(--tf-space-md);
}

html.tf-v2panel .mobile-place-stop.is-active {
  border-color: var(--tf-primary);
  background: var(--tf-bg-elevated);
}

html.tf-v2panel .mobile-place-stop-number {
  background: var(--tf-bg-elevated-2);
  color: var(--tf-text-secondary);
  border-radius: var(--tf-radius-sm);
  font-size: 11px;
  font-weight: 700;
  padding: 2px var(--tf-space-xs);
  line-height: 1.4;
}

html.tf-v2panel .mobile-place-saved-pin-status {
  color: var(--tf-text-muted);
  font-size: 12px;
}

html.tf-v2panel .mobile-place-saved-address {
  color: var(--tf-text-primary);
  font-size: 14px;
  font-weight: 500;
}

html.tf-v2panel .mobile-place-actions {
  display: flex;
  flex-direction: column;
  gap: var(--tf-space-sm);
  margin-top: var(--tf-space-sm);
}

html.tf-v2panel .mobile-place-copy {
  color: var(--tf-text-muted);
  font-size: 12px;
  line-height: 1.5;
}

html.tf-v2panel .mobile-place-input {
  background: var(--tf-bg-elevated);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-sm);
  color: var(--tf-text-primary);
  font-size: 14px;
  padding: var(--tf-space-sm) var(--tf-space-md);
  font-family: inherit;
}

html.tf-v2panel .mobile-place-input:focus {
  outline: none;
  border-color: var(--tf-primary);
  box-shadow: var(--tf-focus-ring);
}


/* ── 3. A46 time-estimates disclaimer modal ───────────────────────────────── */

html.tf-v2panel #time-estimates-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.6);
}

html.tf-v2panel #time-estimates-modal {
  position: fixed;
  inset: 0;
  z-index: 901;
  align-items: center;
  justify-content: center;
  padding: var(--tf-space-lg);
  transform: none;
  /* display flex/none toggled by JS via inline style */
}

html.tf-v2panel #time-estimates-modal .modal-header {
  display: none;
}

html.tf-v2panel #time-estimates-modal .modal-body {
  background: var(--tf-bg-surface);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-lg);
  padding: var(--tf-space-xl);
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--tf-space-md);
}

html.tf-v2panel #time-estimates-modal .tf-modal-mochi {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--tf-mochi-bg);
  border: 2px solid var(--tf-mochi-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  align-self: flex-start;
  flex-shrink: 0;
}

html.tf-v2panel #time-estimates-modal .tf-modal-heading {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--tf-text-primary);
}

html.tf-v2panel #time-estimates-modal .modal-body p {
  font-size: 13px;
  color: var(--tf-text-secondary);
  line-height: 1.6;
  margin: 0;
}

html.tf-v2panel #time-estimates-modal .modal-body .tf-signoff {
  color: var(--tf-text-primary);
  font-style: italic;
}

html.tf-v2panel #time-estimates-close {
  background: var(--tf-primary);
  color: var(--tf-primary-ink);
  border: 0;
  border-radius: var(--tf-radius-md);
  padding: var(--tf-space-md);
  width: 100%;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: var(--tf-tap-min);
  margin-top: var(--tf-space-xs);
}


/* ── 4. Mochi safety pause (Reset / Delete confirm) ──────────────────────── */
/*
   Section 16b lock: safe action is PRIMARY (prominent, filled).
   Applies to BOTH Reset and Delete — Section 16b section meta says
   "User tapped Delete trip or Reset trip." Both get this pattern.
   Copy differentiates consequence (A71). Shape is identical.
*/

html.tf-v2panel #mochi-safety-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0.6);
  display: none;
}

html.tf-v2panel #mochi-safety-backdrop.is-open {
  display: block;
}

html.tf-v2panel #mochi-safety-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--tf-space-lg);
}

html.tf-v2panel #mochi-safety-modal.is-open {
  display: flex;
}

html.tf-v2panel .mochi-safety-card {
  background: var(--tf-bg-elevated);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-lg);
  padding: var(--tf-space-xl) var(--tf-space-lg) var(--tf-space-lg);
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tf-space-md);
  text-align: center;
}

html.tf-v2panel .mochi-safety-icon {
  font-size: 32px;
  line-height: 1;
}

html.tf-v2panel .mochi-safety-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--tf-text-primary);
  line-height: 1.3;
}

html.tf-v2panel .mochi-safety-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--tf-text-secondary);
  max-width: 280px;
  /* Flex layout — copy can grow/shrink without breaking card */
}

/* Mochi-gated pin save — optional name input + hint inside safety modal.
 * Both hidden by default (hidden attribute on element); JS reveals when
 * opts.inputField is provided (pin save/repin flows). */
html.tf-v2panel .mochi-safety-input {
  width: 100%;
  max-width: 280px;
  padding: var(--tf-space-sm) var(--tf-space-md);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-bg-elevated);
  color: var(--tf-text-primary);
  font-size: 14px;
  font-family: inherit;
  min-height: var(--tf-tap-min);
  margin-top: var(--tf-space-xs);
  box-sizing: border-box;
}

html.tf-v2panel .mochi-safety-input:focus-visible {
  outline: none;
  border-color: var(--tf-primary);
  box-shadow: var(--tf-focus-ring);
}

/* Edit C — verified coords display under Edit Pin Stop tab's saved address.
 * Renders only when stop.pinData.locationLocked === true. Bytes-on-screen
 * trust signal: shows the exact lat/lng the user confirmed. */
html.tf-v2panel .mochi-saved-coords {
  margin: var(--tf-space-xs) 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--tf-text-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

html.tf-v2panel .mochi-safety-hint {
  margin: var(--tf-space-xs) 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--tf-text-muted);
  max-width: 280px;
}

html.tf-v2panel .mochi-safety-actions {
  display: flex;
  flex-direction: column;
  gap: var(--tf-space-sm);
  width: 100%;
  margin-top: var(--tf-space-xs);
}

/* Safe action is PRIMARY — Section 16b lock, both Reset and Delete */
html.tf-v2panel .mochi-safety-btn-keep {
  width: 100%;
  padding: var(--tf-space-md);
  border: none;
  border-radius: var(--tf-radius-sm);
  background: var(--tf-primary);
  color: var(--tf-primary-ink);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  min-height: var(--tf-tap-min);
  cursor: pointer;
}

html.tf-v2panel .mochi-safety-btn-keep:hover,
html.tf-v2panel .mochi-safety-btn-keep:focus-visible {
  opacity: 0.92;
  outline: none;
}

/* Confirm action is SECONDARY — danger color, outlined, smaller */
html.tf-v2panel .mochi-safety-btn-confirm {
  width: 100%;
  padding: calc(var(--tf-space-md) - 1px);
  border: 1px solid #c0392b;
  border-radius: var(--tf-radius-sm);
  background: none;
  color: #c0392b;
  font-size: 14px;
  font-family: inherit;
  min-height: var(--tf-tap-min);
  cursor: pointer;
}

html.tf-v2panel .mochi-safety-btn-confirm:hover,
html.tf-v2panel .mochi-safety-btn-confirm:focus-visible {
  background: rgba(192, 57, 43, 0.06);
  outline: none;
}


/* ── 5. About Tabiflow modal (Panel C) ───────────────────────────────────── */
/*
 * Triggered by handleHbgAction('about') — hamburger drawer ≡ → "About Tabiflow".
 * Opened / closed by openAboutModal() / closeAboutModal() in planner-page.js.
 * Both elements use inline style="display:none" in HTML so V1 users never see
 * card content — same pattern as #time-estimates-modal.
 * .is-open classes toggle visibility; !important defeats the inline style.
 * z-index map: same level as mochi-safety (299/300) — cannot be open simultaneously.
 */

html.tf-v2panel #tf-about-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0.6);
  display: none;
}

html.tf-v2panel #tf-about-backdrop.is-open {
  display: block !important;
}

html.tf-v2panel #tf-about-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--tf-space-lg);
}

html.tf-v2panel #tf-about-modal.is-open {
  display: flex !important;
}

html.tf-v2panel .about-card {
  background: var(--tf-bg-elevated);
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-lg);
  padding: var(--tf-space-lg);
  max-width: 320px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--tf-space-md);
}

html.tf-v2panel .about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tf-space-sm);
}

html.tf-v2panel .about-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tf-text-primary);
  flex: 1;
}

html.tf-v2panel .about-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--tf-text-secondary);
  cursor: pointer;
  min-height: var(--tf-tap-min);
  min-width: var(--tf-tap-min);
  border-radius: var(--tf-radius-md);
  transition: background 0.1s;
  padding: 0;
  font-family: inherit;
  line-height: 1;
  flex-shrink: 0;
}

html.tf-v2panel .about-close:hover,
html.tf-v2panel .about-close:focus-visible {
  background: var(--tf-bg-surface);
  outline: none;
}

html.tf-v2panel .about-body {
  display: flex;
  flex-direction: column;
  gap: var(--tf-space-md);
}

html.tf-v2panel .about-version {
  font-size: 13px;
  color: var(--tf-text-muted);
}

html.tf-v2panel .about-links {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--tf-border-soft);
  border-radius: var(--tf-radius-md);
  overflow: hidden;
}

html.tf-v2panel .about-link {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--tf-primary);
  text-decoration: none;
  padding: var(--tf-space-md) var(--tf-space-lg);
  min-height: var(--tf-tap-min);
  border-bottom: 1px solid var(--tf-border-soft);
  transition: background 0.1s;
}

html.tf-v2panel .about-link:last-child {
  border-bottom: none;
}

html.tf-v2panel .about-link:hover,
html.tf-v2panel .about-link:active {
  background: var(--tf-bg-surface);
}

html.tf-v2panel .about-link:focus-visible {
  outline: none;
  box-shadow: var(--tf-focus-ring);
}
