/* iPad and other touch screens. Loaded after app.css.
   Finger-sized controls, no hover-only actions, the keyboard never hides what you're typing in,
   and the customer hand-off sheet (signatures, credit app, portal) that stays inside the app. */

@media (pointer: coarse) {
  /* Apple's guideline is a 44pt touch target. Small buttons stay small to the eye but get taller to tap. */
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not(.switch), select { min-height: 44px; }
  input[type=checkbox]:not(.switch), input[type=radio] { min-width: 20px; min-height: 20px; }
  .chk { min-height: 36px; }
  button, .btn, a, label, summary, [role=button] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  .btn, button { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

  /* Header menus behind ☰: bigger rows */
  .topbar #nav .nav-menu a { padding: 12px 12px; }
  .topbar #nav > a.nav-solo { padding: 12px 14px; }
  .topbar .bell, .topbar .me { min-width: 40px; min-height: 40px; display: inline-grid; place-items: center; }
  .topbar #reportBtn { min-width: 36px; min-height: 40px; }

  /* Tabs, segmented buttons, chips and text links: taller to tap */
  .seg button, .dk-tab, .dp-tab, .chip-btn, .stip { min-height: 40px; }
  .avatar.av-btn { min-width: 36px; min-height: 36px; }
  button.check { min-width: 28px; min-height: 28px; }
  /* Inline text buttons grow their tap area without moving the text around them */
  .link-btn, .mkt-chip, .src-chip, .cp-chip, .cv-chip, #openAll, #manageCat { padding-top: 8px; padding-bottom: 8px; margin-top: -8px; margin-bottom: -8px; }

  /* Things that only showed on mouse-over */
  .cust-head .head-veh .head-edit { opacity: 1; }
  button.av-btn::after { opacity: 0; }

  /* Desk: number boxes are easy to hit with a thumb but keep the sheet compact */
  .dk-line input, .dk-ro, .dk-body input, .dk-body select, .dk-pg select, .dk-pg input { min-height: 40px; font-size: 15px; }

  /* F&I menu: chips and their ✕ / price are separate targets */
  .fi-chip { min-height: 44px; }
  .fi-chip .fi-x { min-width: 36px; min-height: 36px; }
  .fi-chip .fi-price { min-height: 32px; padding: 2px 6px; }

  /* Signature pad: more room for a finger or Apple Pencil */
  .sg-pad { height: 220px; }
}

/* Modals fit above the on-screen keyboard (dvh shrinks when the keyboard opens) */
@supports (height: 1dvh) { .modal-card { max-height: 90dvh; } }

/* While the on-screen keyboard is up, floating buttons and pop-ups get out of the way */
html.kb-open #fab, html.kb-open .live-stack, html.kb-open .coach-panel, html.kb-open .install-tip { display: none !important; }

/* ---------- Hand to the customer: a full-screen sheet over the CRM ---------- */
.handoff { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; grid-template-rows: auto 1fr; }
.handoff-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--panel); }
.handoff-bar b { font-size: 16px; }
.handoff-bar .muted { font-size: 14px; }
.handoff-bar .spacer { flex: 1; }
.handoff iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.handoff.done .handoff-bar { background: var(--ok-soft); }
html.handoff-on, html.handoff-on body { overflow: hidden; }

/* ---------- Add to Home Screen tip (iPad / iPhone Safari only) ---------- */
.install-tip { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 45; width: min(520px, calc(100vw - 24px)); display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg, 0 18px 40px -12px rgba(0,0,0,.45)); font-size: 15px; }
.install-tip img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.install-tip .grow { flex: 1; min-width: 0; }
.install-tip .share-ico { display: inline-block; vertical-align: -3px; width: 16px; height: 18px; }

/* Opened from the Home Screen: no browser bar, so keep clear of the status bar */
@media (display-mode: standalone) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
}

/* ---------- Desk on an iPad in portrait (mini through 13") ----------
   Finance details on the left, payments on the right, like landscape, instead of one long column
   where the payment grid is a long scroll away from the numbers that change it. */
@media (min-width: 740px) and (max-width: 1100px) {
  .dk-grid:not(.wide) { grid-template-columns: minmax(0, 280px) minmax(0, 1fr); }
  .dk-grid:not(.wide) .dk-left { position: sticky; top: 70px; max-height: calc(100dvh - 86px); overflow-y: auto; }
  .dk-grid:not(.wide) .dk-pg { min-width: 0; gap: 6px 5px; --pg-in: 50px; --pg-cell: 72px; --pg-cell4: 64px; }
  .dk-grid:not(.wide) .dk-pg select, .dk-grid:not(.wide) .dk-pg input { padding-left: 6px; padding-right: 2px; }
  .dk-grid:not(.wide) .dk-money input { padding-left: 16px; } .dk-grid:not(.wide) .dk-money::before { left: 6px; }
  .dk-grid:not(.wide) .dk-pct input { padding-right: 16px; } .dk-grid:not(.wide) .dk-pct::after { right: 5px; }
  .dk-grid:not(.wide) .dk-pg-lbl { font-size: 11px; letter-spacing: .02em; }
  .dk-grid:not(.wide) .dk-cell { font-size: 16px; padding: 6px 2px; }
}

/* ---------- F&I menu ---------- */
.fi-drop { grid-template-columns: minmax(0, 1fr); }
.fi-chip { min-width: 0; }
/* On touch the ⋮⋮ grip goes (touch and hold anywhere on a product to drag it, or tap it to move it) so names have room */
@media (pointer: coarse) { .fi-chip .fi-x { min-width: 30px; padding: 2px; } .fi-chip { gap: 8px; padding: 6px 4px 6px 10px; } .fi-chip .fi-grip { display: none; } }
@media (max-width: 1279px) { .fi-sc { padding: 10px 8px; } .fi-drop { padding: 4px 2px; } }

/* ---------- Top bar safety net (any screen) ----------
   tablet.js adds these when the bar still doesn't fit (a manager with every menu, several stores, browser zoom or
   bigger text), one step at a time, so nothing runs off the right edge.
   tb-tight: drop the extra labels. tb-tighter: search folds into the ⌕ button and the store picker and duty button shrink. */
html.tb-tight .topbar #nav .nav-here, html.tb-tight .topbar > .brand .brand-text, html.tb-tight .topbar .lead-clock .lc-name, html.tb-tight .topbar #themeBtn, html.tb-tight .topbar #newLeadBtn .nl-word { display: none; }
html.tb-tighter .topbar .search-wrap { display: none; }
html.tb-tighter body.search-open .topbar .search-wrap { display: block; position: absolute; left: 10px; right: 10px; top: calc(100% + 6px); z-index: 80; }
html.tb-tighter .topbar .search-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 20px; cursor: pointer; flex: none; }
html.tb-tighter .topbar .loc-pick { max-width: 130px; }
html.tb-tighter .topbar #nav .nav-group, html.tb-tighter .topbar #nav > a.nav-solo { padding: 8px 6px; }
