/* Field Mode in the IOVO design system (UI overhaul part 4). Visual layer only: Field Mode keeps all of its markup, ids, data and
   handlers. Loaded after the page's own styles and after iovo-ui.css / iovo-field-ui.css; every rule is scoped to html[data-ds] so
   the page keeps its previous look when the shared files are missing. Tokens only (--ds-*), 4 px grid, one accent per brand,
   phone-first, large touch targets, motion 150-250 ms ease-out with no bounce. */

/* ── field tokens resolve to the shared tokens (page-local names Field Mode already uses) ── */
html[data-ds]:root:not(#_) {
  --card2: var(--ds-surface-2);
  --line-hi: var(--ds-accent-line);
  --panel-glow: transparent;
  --route-bg: var(--ds-surface);
  --body-grad: none;
  --surface-top: var(--ds-surface);
  --surface-bottom: var(--ds-surface);
  --hero-top: var(--ds-surface);
  --hero-bottom: var(--ds-surface);
  --glass-sheen: var(--ds-hover);
  --chip-bg: var(--ds-surface-2);
  --chip-active: var(--ds-accent-soft);
  --text-glow: none;
  --fm-glass-top: var(--ds-surface);
  --fm-glass-bottom: var(--ds-surface);
  --fm-glass-line: var(--ds-border);
  --fm-onmap-top: var(--ds-surface);
  --fm-onmap-bottom: var(--ds-surface);
  --fm-onmap-line: var(--ds-border-strong);
  --fm-onmap-shadow: var(--ds-shadow-md);
  --fm-sheen: transparent;
  --radius: var(--ds-radius-lg);
  --fm-r-lg: var(--ds-radius-lg);
  --fm-r-md: var(--ds-radius-md);
  --fm-r-sm: var(--ds-radius-sm);
  --shadow: var(--ds-shadow-sm);
}
html[data-ds], html[data-ds] body { background: var(--ds-bg); }
html[data-ds] body::after { display: none; }
html[data-ds] a:focus-visible, html[data-ds] button:focus-visible, html[data-ds] input:focus-visible, html[data-ds] select:focus-visible,
html[data-ds] textarea:focus-visible, html[data-ds] [tabindex]:focus-visible, html[data-ds] summary:focus-visible { outline: none; box-shadow: var(--ds-focus); }

/* ── top bar: flat, one row, brand mark + page title ── */
html[data-ds] .topbar { gap: var(--ds-space-3); min-height: 56px; padding: var(--ds-space-2) var(--ds-space-3); border-color: var(--ds-border); border-radius: var(--ds-radius-lg); background: var(--ds-surface); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
html[data-ds] .brand { display: flex; align-items: center; gap: var(--ds-space-2); min-width: 0; }
html[data-ds] .brand .fd-brand-mark { flex: none; width: 28px; height: 28px; border-radius: var(--ds-radius-sm); }
html[data-ds] .brand-text { display: grid; gap: 0; min-width: 0; }
html[data-ds] .eyebrow { color: var(--ds-text-3); font: var(--ds-weight-medium) var(--ds-text-2xs)/1.3 var(--ds-font-sans); letter-spacing: .08em; text-shadow: none; }
html[data-ds] .title { font: var(--ds-weight-semibold) var(--ds-text-lg)/1.25 var(--ds-font-sans); letter-spacing: -.01em; text-shadow: none; }
html[data-ds] .top-actions { gap: var(--ds-space-2); min-width: 0; flex-wrap: wrap; }

/* ── buttons, segmented switches, tabs, chips: shared look ── */
html[data-ds] .theme-btn, html[data-ds] .ghost-btn, html[data-ds] .small-btn, html[data-ds] .tab-btn, html[data-ds] .choice-btn {
  min-height: var(--ds-hit); border: 1px solid var(--ds-control-border); border-radius: var(--ds-radius-md); background: var(--ds-surface-2); color: var(--ds-text); box-shadow: none;
  font: var(--ds-weight-medium) var(--ds-text-sm)/1.25 var(--ds-font-sans); letter-spacing: 0; text-transform: none;
  transition: background-color var(--ds-dur-fast) var(--ds-ease), border-color var(--ds-dur-fast) var(--ds-ease), transform var(--ds-dur-fast) var(--ds-ease);
}
html[data-ds] .theme-btn:hover, html[data-ds] .ghost-btn:hover, html[data-ds] .small-btn:hover, html[data-ds] .tab-btn:hover, html[data-ds] .choice-btn:hover { transform: none; background: var(--ds-selected); border-color: var(--ds-control-border); box-shadow: none; }
html[data-ds] .theme-btn:active, html[data-ds] .ghost-btn:active, html[data-ds] .small-btn:active, html[data-ds] .tab-btn:active, html[data-ds] .choice-btn:active, html[data-ds] .primary-btn:active, html[data-ds] .action-btn:active { transform: scale(.96); }
html[data-ds] .primary-btn, html[data-ds] .small-btn.primary { min-height: 52px; border: 0; border-radius: var(--ds-radius-md); background: var(--ds-accent); color: var(--ds-accent-fg); box-shadow: none; font: var(--ds-weight-semibold) var(--ds-text-md)/1.25 var(--ds-font-sans); }
html[data-ds] .primary-btn:hover, html[data-ds] .small-btn.primary:hover { background: var(--ds-accent-strong); box-shadow: none; transform: none; }
html[data-ds] .small-btn.primary { min-height: var(--ds-hit); }
html[data-ds] .tab-btn.active, html[data-ds] .choice-btn.active { background: var(--ds-accent-soft); border-color: var(--ds-accent-line); color: var(--ds-accent-text); box-shadow: none; }
html[data-ds] .lang-switch, html[data-ds] .segmented, html[data-ds] .glass-switch { padding: var(--ds-space-1); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); background: var(--ds-surface-2); box-shadow: none; }
html[data-ds] .lang-btn, html[data-ds] .seg-btn, html[data-ds] .glass-btn { min-height: 36px; border-radius: var(--ds-radius-sm); color: var(--ds-text-2); font: var(--ds-weight-medium) var(--ds-text-xs)/1 var(--ds-font-sans); letter-spacing: .04em; }
html[data-ds] .lang-btn.active, html[data-ds] .seg-btn.active, html[data-ds] .glass-btn.active { background: var(--ds-accent); color: var(--ds-accent-fg); box-shadow: none; }
html[data-ds] .lang-btn:not(.active):hover, html[data-ds] .seg-btn:not(.active):hover, html[data-ds] .glass-btn:not(.active):hover { transform: none; background: var(--ds-hover); color: var(--ds-text); }
html[data-ds] .seg-btn.coming-soon:not(.active) { color: var(--ds-warning); }
html[data-ds] .seg-btn.coming-soon.active { background: var(--ds-warning); color: var(--ds-bg); box-shadow: none; }
html[data-ds] .home-link { width: var(--ds-hit); min-width: var(--ds-hit); border-radius: var(--ds-radius-md); }
/* header controls keep the shared 44 px hit floor at every width: the page's own phone/tablet sizes (32/36/40 px, 28 px knock/hanger
   icons) sat below it. The three selectors out-specify the page's late phone rules and the pointer:coarse 40 px rule above. */
html[data-ds] .top-actions .lang-btn { min-height: var(--ds-hit); min-width: var(--ds-hit); }
html[data-ds] #fmModeToggle .fm-mode-btn { justify-content: center; min-height: var(--ds-hit); min-width: var(--ds-hit); }
/* Sign out: iovo-ui.css styles every .signout-btn as the full-width sidebar row (width:100%, 32/40 px tall, left aligned,
   specificity 1,2,1 via :not(#_)). In the Field header that made it as wide as the row and shorter than the hit floor at 440 px and
   up (the collapsed <=430 px icon button is pinned by the page's own more specific rule). This one out-specifies it (1,2,2) and
   restores a content-sized control at the shared hit floor; the label, icon swap and margin-left:auto placement are untouched. */
html[data-ds] body .top-actions #fieldModeSignOutBtn { width: auto; height: auto; min-width: var(--ds-hit); min-height: var(--ds-hit); flex: 0 0 auto; justify-content: center; padding: 0 var(--ds-space-3); text-align: center; }

/* icon-only buttons keep their own size and hidden label (they set font-size:0) */
html[data-ds] .fm-icon-btn { font-size: 0; min-height: 0; border-radius: var(--ds-radius-md); }
html[data-ds] .fm-rail-btn:hover, html[data-ds] .hang-map-chip:hover { background: var(--ds-hover); color: var(--ds-text); }
html[data-ds] .fm-rail-btn:active, html[data-ds] .fm-rail-btn.is-active { color: var(--ds-accent-text); background: var(--ds-accent-soft); border-color: var(--ds-accent-line); }
html[data-ds] .hang-map-chip { min-height: 36px; border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-md); background: var(--ds-surface-2); color: var(--ds-text-2); box-shadow: none; font: var(--ds-weight-medium) var(--ds-text-sm)/1.2 var(--ds-font-sans); letter-spacing: 0; text-transform: none; }
html[data-ds] .hang-map-chip.active { border-color: var(--ds-accent-line); background: color-mix(in srgb, var(--ds-accent) 12%, var(--ds-surface)); color: var(--ds-accent-text); }

/* ── surfaces: flat panels with a hairline, no glow, no sheen line ── */
html[data-ds] .section { border-color: var(--ds-border); border-radius: var(--ds-radius-lg); background: var(--ds-surface); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
html[data-ds] .section::before, html[data-ds] .section::after { display: none; }
html[data-ds] .hero { border-color: var(--ds-border); }
html[data-ds] .section-title { font: var(--ds-weight-semibold) var(--ds-text-md)/1.3 var(--ds-font-sans); letter-spacing: 0; }
html[data-ds] .section-copy { color: var(--ds-text-2); font-size: var(--ds-text-sm); line-height: 1.5; }
html[data-ds] .status-pill, html[data-ds] .micro-pill { padding: 2px var(--ds-space-2); min-height: 24px; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-pill); background: var(--ds-surface-2); color: var(--ds-text-2); font: var(--ds-weight-medium) var(--ds-text-xs)/1.25 var(--ds-font-sans); font-variant-numeric: tabular-nums; }
html[data-ds] .micro-pill.proposal-generated, html[data-ds] .micro-pill.proposal-presented { background: color-mix(in srgb, var(--ds-accent) 12%, var(--ds-surface)); border-color: var(--ds-accent-line); color: var(--ds-accent-text); }
html[data-ds] input, html[data-ds] select, html[data-ds] textarea { min-height: var(--ds-hit); border: 1px solid var(--ds-control-border); border-radius: var(--ds-radius-md); background: var(--ds-bg); color: var(--ds-text); transition: border-color var(--ds-dur-fast) var(--ds-ease); }
html[data-ds] input:focus, html[data-ds] select:focus, html[data-ds] textarea:focus { background: var(--ds-bg); border-color: var(--ds-accent-text); }
html[data-ds] input::placeholder, html[data-ds] textarea::placeholder { color: var(--ds-text-3); }
/* native checkboxes stay a normal box beside their label (the label row is the touch target), not a 44 px stretched field */
html[data-ds] input:is([type="checkbox"], [type="radio"]) { width: 20px; height: 20px; min-height: 0; margin: 0 var(--ds-space-2) 0 0; padding: 0; vertical-align: middle; accent-color: var(--ds-accent); }

/* ── today's list: schedule rows as a dense, divided list instead of floating cards ── */
html[data-ds] .list { gap: 0; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); overflow: hidden; background: var(--ds-surface); }
html[data-ds] .list:empty { display: none; }
html[data-ds] .item { gap: var(--ds-space-2); padding: var(--ds-space-3) var(--ds-space-4); border: 0; border-top: 1px solid var(--ds-border); border-radius: 0; background: transparent; box-shadow: none; transition: background-color var(--ds-dur-fast) var(--ds-ease); }
html[data-ds] .item:first-child { border-top: 0; }
html[data-ds] .item:hover { background: var(--ds-hover); }
html[data-ds] .item-title { font: var(--ds-weight-medium) var(--ds-text-lg)/1.3 var(--ds-font-sans); overflow-wrap: anywhere; }
html[data-ds] .item-meta { color: var(--ds-text-2); font-size: var(--ds-text-sm); line-height: 1.45; overflow-wrap: anywhere; }
html[data-ds] .schedule-timeline { border-color: var(--ds-border); border-radius: var(--ds-radius-lg); background: var(--ds-surface); }
html[data-ds] .schedule-divider { background: var(--ds-border); }
html[data-ds] .schedule-header { flex-wrap: wrap; }
html[data-ds] .schedule-actions { flex-wrap: wrap; }

/* ── outcome buttons (knock tracker): flat tiles, outcome colour only on the text, big targets ── */
html[data-ds] .action-btn { min-height: 64px; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-lg); background: var(--ds-surface-2); box-shadow: none; transition: background-color var(--ds-dur-fast) var(--ds-ease), transform var(--ds-dur-fast) var(--ds-ease); }
html[data-ds] .action-btn::after { display: none; }
html[data-ds] .action-btn:hover { background: var(--ds-selected); }
html[data-ds] .action-btn:active { box-shadow: none; }
html[data-ds] .action-btn.convo, html[data-ds] .action-btn.appt, html[data-ds] .action-btn.dnk, html[data-ds] .action-btn.followup, html[data-ds] .action-btn.inhome { border-color: var(--ds-border); }
html[data-ds] .action-btn .action-count { font-variant-numeric: tabular-nums; }
html[data-ds] .action-btn.convo .action-count, html[data-ds] .action-btn.convo .action-label { color: var(--ds-info); }
html[data-ds] .action-btn.appt .action-count, html[data-ds] .action-btn.appt .action-label { color: var(--ds-success); }
html[data-ds] .action-btn.dnk .action-count, html[data-ds] .action-btn.dnk .action-label { color: var(--ds-danger); }
html[data-ds] .action-btn.followup .action-count, html[data-ds] .action-btn.followup .action-label { color: var(--ds-warning); }
html[data-ds] .action-btn.inhome .action-count, html[data-ds] .action-btn.inhome .action-label { color: var(--ds-accent-text); }

/* ── bottom tab bar: flat, solid, 56 px items with an accent top indicator on the active tab ── */
html[data-ds] .footer-nav, html[data-ds][data-theme] .footer-nav { gap: 0; padding: 0 var(--ds-space-2) env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--ds-border-strong); background: var(--ds-surface); }
html[data-ds] .footer-nav::before, html[data-ds] .footer-nav::after, html[data-ds] .footer-nav-solid { background: var(--ds-surface); }
html[data-ds] .footer-nav button, html[data-ds] .footer-nav a { position: relative; min-height: 56px; border: 0; border-radius: 0; background: none; color: var(--ds-text-2); font: var(--ds-weight-medium) var(--ds-text-xs)/1.2 var(--ds-font-sans); letter-spacing: 0; transition: color var(--ds-dur-fast) var(--ds-ease), background-color var(--ds-dur-fast) var(--ds-ease); }
html[data-ds] .footer-nav button:hover { background: var(--ds-hover); }
html[data-ds] .footer-nav .active { background: none; color: var(--ds-accent-text); }
html[data-ds] .footer-nav .active::before { filter: none; }
html[data-ds] .footer-nav .active::after { content: ''; position: absolute; left: var(--ds-space-4); right: var(--ds-space-4); top: 0; height: 2px; border-radius: 0 0 2px 2px; background: var(--ds-accent); }
html[data-ds] .footer-nav button { flex-direction: column; gap: var(--ds-space-1); }
@media (min-width: 640px) { html[data-ds] .footer-nav button { flex-direction: row; gap: var(--ds-space-2); } }

html[data-ds] .hero #sessionPrimaryBtn { min-height: var(--ds-hit); padding: 0 var(--ds-space-4); border: 0; border-radius: var(--ds-radius-md); background: var(--ds-accent); color: var(--ds-accent-fg); font: var(--ds-weight-semibold) var(--ds-text-sm)/1.2 var(--ds-font-sans); }
html[data-ds] .hero #sessionSecondaryBtn { min-height: var(--ds-hit); }
html[data-ds] .session-goals-strip, html[data-ds] .session-goals-strip-chip { border-color: var(--ds-border); background: none; }
html[data-ds] .session-goals-strip-chip strong, html[data-ds] .session-goals-strip-pct { font-family: var(--ds-font-sans); font-variant-numeric: tabular-nums; }

/* ── dialogs and toasts ── */
html[data-ds] .modal-card { border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-lg); background: var(--ds-surface); box-shadow: var(--ds-shadow-lg); }
html[data-ds] .toast { border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-md); background: var(--ds-surface); color: var(--ds-text); box-shadow: var(--ds-shadow-md); font-size: var(--ds-text-md); transition: opacity var(--ds-dur) var(--ds-ease), transform var(--ds-dur) var(--ds-ease); }
html[data-ds] .fm-glass-on-map { border-color: var(--ds-border-strong); }

/* ── phones: bigger text controls, wrap instead of clip (English and Spanish) ── */
@media (max-width: 479px) {
  /* brand on its own row, controls below: the page title is never cut to an ellipsis (EN and ES) */
  html[data-ds] .topbar, html[data-ds] body:not(.fm-map-shell) .topbar { container-type: inline-size; container-name: fmtop; flex-wrap: wrap; row-gap: var(--ds-space-2); column-gap: var(--ds-space-2); }
  html[data-ds] .topbar .brand:not(#_) { order: 1; flex: 1 0 100%; min-width: 0; }
  html[data-ds] .brand .title { overflow: visible; text-overflow: clip; white-space: normal; font-size: var(--ds-text-lg); }
  /* controls reflow onto a second row instead of pushing Sign out past the card edge; Sign out takes the free space on its row */
  html[data-ds] .topbar .top-actions { order: 3; flex: 1 0 100%; justify-content: flex-start; flex-wrap: wrap; gap: var(--ds-space-2); }
  html[data-ds] .top-actions > * { flex-shrink: 0; }
  html[data-ds] .top-actions #fieldModeSignOutBtn { margin-left: auto; }
  html[data-ds] .top-actions .theme-btn { flex: 0 0 var(--ds-hit); width: var(--ds-hit); min-width: var(--ds-hit); height: var(--ds-hit); min-height: var(--ds-hit); }
  /* Keep the existing icon-only Sign out treatment through 479px: restoring "Cerrar sesión"
     above the legacy 430px breakpoint would make the controls wider just as the container grows. */
  html[data-ds] body .topbar .top-actions #fieldModeSignOutBtn { width: var(--ds-hit); height: var(--ds-hit); padding: 0; display: grid; place-items: center; line-height: 0; }
  html[data-ds] .topbar #fieldModeSignOutBtn [data-fm-icon] { display: block; }
  html[data-ds] .topbar #fieldModeSignOutBtn .signout-label { display: none; }
  /* The wrappers add no height above their 44px buttons on the controls row at any phone width.
     Rule 34: the header never grows, the map keeps its height. */
  html[data-ds] .topbar .top-actions .lang-switch { padding-block: 0; border-block-width: 0; }
  html[data-ds] .topbar .top-actions #fmModeToggle { border-block-width: 0; }
  /* Rule 34: keep Home in flow and never add a header line that shrinks the map.
     Controls with Home need 90 (mode) + 44 (theme) + 98 (language) + 44 (Sign out)
     + 44 (Home) + 4 * 8 (gaps) = 352px. Below 360px of content width, reserve
     Home on the title row; the remaining controls need only 300px. Wider rows keep r0's title height. */
  @container fmtop (max-width: 359.98px) {
    html[data-ds] .topbar .top-actions { display: contents; }
    html[data-ds] .topbar .brand:not(#_) { order: 1; flex: 0 0 calc(100% - var(--ds-hit) - var(--ds-space-2)); align-self: stretch; }
    html[data-ds] .topbar .top-actions > * { order: 3; }
    html[data-ds] .topbar .top-actions #dashboardLink { order: 2; margin: 0; }
  }
}
/* Schedule header on phones and small tablets: two even rows, never a ragged right-aligned wrap (Daniel, Oct 18).
   Row 1: the day tabs share the width. Row 2: the three actions share the width; New Appointment is the primary one. */
@media (max-width: 767px) {
  html[data-ds] .schedule-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--ds-space-2); align-items: stretch; }
  html[data-ds] #scheduleTabs, html[data-ds] .schedule-actions { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--ds-space-2); flex-wrap: nowrap; justify-content: stretch; }
  html[data-ds] #scheduleTabs .tab-btn, html[data-ds] .schedule-actions > .ghost-btn { width: 100%; min-width: 0; padding-inline: var(--ds-space-2); white-space: normal; line-height: 1.15; text-align: center; justify-content: center; }
  html[data-ds] .schedule-actions > #scheduleNewBtn { background: var(--ds-accent); border-color: var(--ds-accent); color: var(--ds-accent-fg); }
}
@media (pointer: coarse) { html[data-ds] .fm-rail-btn { width: var(--ds-hit); min-width: var(--ds-hit); height: var(--ds-hit); min-height: var(--ds-hit); } }
@media (pointer: coarse) {
  html[data-ds] .ghost-btn, html[data-ds] .small-btn, html[data-ds] .tab-btn, html[data-ds] .choice-btn { min-height: 48px; }
  html[data-ds] .lang-btn, html[data-ds] .seg-btn, html[data-ds] .glass-btn { min-height: 40px; min-width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-ds] .theme-btn, html[data-ds] .ghost-btn, html[data-ds] .small-btn, html[data-ds] .tab-btn, html[data-ds] .choice-btn, html[data-ds] .action-btn, html[data-ds] .item, html[data-ds] .footer-nav button, html[data-ds] .toast, html[data-ds] input { transition: none; }
  html[data-ds] .theme-btn:active, html[data-ds] .ghost-btn:active, html[data-ds] .small-btn:active, html[data-ds] .tab-btn:active, html[data-ds] .choice-btn:active, html[data-ds] .primary-btn:active, html[data-ds] .action-btn:active { transform: none; }
}
