/* ═══════════════════════════════════════════════════════
   EQ Solves — Field  ·  mobile.css
   v3.3.3 — mobile polish pass
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Visibility helpers ───────────────────────────── */
  .hide-mobile { display: none !important; }
  .show-mobile { display: inline !important; }

  /* ── Layout ──────────────────────────────────────── */
  .sidebar   { display: none; }
  .content   { margin-left: 0 !important; }
  .topbar    {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: nowrap;            /* single row on mobile */
    overflow: hidden;
  }
  .topbar-title { font-size: 15px; flex-shrink: 0; }

  /* Hide stat pills + action buttons — declutter mobile header */
  .topbar .pill { display: none; }
  .topbar-actions .btn { display: none; }

  /* Show a compact sync icon on mobile */
  .topbar-actions .btn#refresh-btn {
    display: inline-flex;
    min-height: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 16px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }

  /* Week picker — compact but tappable */
  .topbar-week {
    flex: 1;
    min-width: 0;                /* allow the picker to shrink so the sync
                                   icon stays on-screen (was clipped on the
                                   roster/schedule topbar at ≤375px) */
    justify-content: center;
    min-height: 38px;
    padding: 4px 8px;
  }
  /* The long "Week Starting …" label is redundant on mobile — the week
     <select> already shows the current week, and the label wrapped into an
     ugly multi-line block while pushing the row past the viewport. Hide it
     and let the select take the freed space. */
  .topbar-week #week-label-text { display: none; }
  .topbar-week #globalWeek { min-width: 0; flex: 1 1 auto; }
  .topbar-week button { min-width: 32px; min-height: 32px; font-size: 18px; }

  .page      { padding: 12px; }

  /* ── Last updated bar — slimmer on mobile ────────── */
  #last-updated-bar {
    padding: 4px 12px;
    font-size: 11px;
    gap: 6px;
  }
  #last-updated-bar span { font-size: 11px !important; }

  /* ── Stats ───────────────────────────────────────── */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card-value { font-size: 22px; }

  /* ── Tables — scroll ─────────────────────────────── */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Editor — scroll ─────────────────────────────── */
  .roster-editor-row { min-width: 600px; }

  /* ── Filter row ──────────────────────────────────── */
  .filter-row { gap: 6px; }
  .search-wrap { max-width: 100%; min-width: 0; flex: 1 1 100%; }
  .filter-select { flex: 1 1 45%; min-width: 0; font-size: 13px; }
  /* Timesheets: the trailing hint + "⚡ Batch Fill" group is a nowrap flex
     box wider than the viewport; drop it onto its own full-width row so the
     button is reachable without horizontal scroll. */
  #page-timesheets .filter-row > div:last-child {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
  }

  /* ── Section header ──────────────────────────────── */
  .section-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .section-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: 0 !important;
  }
  /* Dashboard filter inputs — stack on mobile */
  #dash-site-filter  { width: 100% !important; flex: 1 1 100%; }
  #dash-group-filter { width: auto !important; flex: 1 1 60%; }

  /* ── Section actions — wrap buttons ──────────────── */
  .section-actions { flex-wrap: wrap; gap: 6px; }

  /* ── Form rows ───────────────────────────────────── */
  .form-row { flex-direction: column; gap: 0; }

  /* ── Buttons — min touch target ──────────────────── */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 13px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; font-size: 12px; }
  .btn-icon { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .modal-close { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }

  /* ── Forms — larger inputs on mobile ─────────────── */
  .form-input, .form-select { font-size: 16px; padding: 10px 12px; }
  /* 16px prevents iOS zoom-on-focus */

  /* ── Modal — bottom sheet ────────────────────────── */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    max-width: 100%;
    width: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px env(safe-area-inset-bottom, 12px); }

  /* ── Toast ───────────────────────────────────────── */
  .toast { bottom: 80px; font-size: 12px; }

  /* ── EQ Agent ────────────────────────────────────── */
  #eq-agent-fab    { bottom: 72px; }
  #eq-agent-panel  { bottom: 124px; width: calc(100vw - 32px); right: 16px; }

  /* ── Mobile bottom nav ───────────────────────────── */
  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0 2px env(safe-area-inset-bottom, 0px);  /* iPhone notch safe */
    align-items: stretch;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 9px;
    font-weight: 600;
    color: var(--ink-4);
    cursor: pointer;
    padding: 4px 1px;
    min-width: 0;                             /* allow flex shrink for 5 items */
    transition: color .12s, transform .1s;
    text-transform: uppercase;
    letter-spacing: .2px;
    border-top: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item:active { transform: scale(.92); opacity: .7; }
  .mobile-nav-item.active {
    color: var(--navy);
    border-top-color: var(--navy);
  }
  .mnav-icon { font-size: 19px; line-height: 1; }

  /* ── Mobile drawer ───────────────────────────────── */
  #mobile-drawer {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
  }
  #mobile-drawer.open { pointer-events: all; }

  #mobile-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13,27,42,.5);
    opacity: 0;
    transition: opacity .25s;
  }
  #mobile-drawer.open #mobile-drawer-backdrop { opacity: 1; }

  #mobile-drawer-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 12px 0 env(safe-area-inset-bottom, 20px);
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;             /* stops pull-to-refresh on drawer scroll */
  }
  #mobile-drawer.open #mobile-drawer-panel { transform: translateY(0); }

  .drawer-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  .drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;                       /* was 13px — meets 44px min */
    min-height: 48px;                         /* explicit touch target */
    background: none;
    border: none;
    font-family: inherit;
    font-size: 15px;                          /* was 14px */
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
  }
  .drawer-item:active { background: var(--surface-2); }
  .drawer-item:hover  { background: var(--surface-2); }
  .drawer-item.active-page { color: var(--navy); font-weight: 700; }
  .drawer-item.edit-only   { display: none; }
  .manager-mode .drawer-item.edit-only { display: flex; }
  .drawer-item.locked   { color: var(--ink-3); }
  .drawer-item.unlocked { color: var(--green); }
  .d-icon { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
  .drawer-divider { height: 1px; background: var(--border); margin: 4px 0; }
  .drawer-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--ink-3);
    padding: 10px 20px 4px;                   /* was 8px top — a bit more room */
  }
  .drawer-item .beta-tag {
    font-size: 9px;
    font-weight: 700;
    color: var(--amber);
    background: var(--amber-lt);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: auto;
  }

  /* ── Page padding for nav ────────────────────────── */
  .page { padding-bottom: 76px; }             /* accounts for nav + safe area */

  /* ── Swipe hint hidden (no longer needed) ────────── */
  #roster-swipe-hint { display: none !important; }

  /* ── Active page indicator — subtle dot under icon ── */
  .mobile-nav-item.active .mnav-icon::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--navy);
    margin: 2px auto 0;
  }

  /* ── Mobile roster — Direction C person strips ─────
     v8 (roster-v8): the read-only roster grid is replaced on phones by
     stacked person cards (avatar + name + crew + mini M–S week strip).
     renderRoster builds both presentations; here we hide the desktop grid
     and reveal the person strips. The EDITOR keeps its own horizontal-scroll
     row layout (.roster-editor-row min-width below) — untouched. */
  #page-roster .roster-desktop { display: none; }
  #page-roster .roster-mobile  { display: block; }

}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 12px; }
  .stat-card-value { font-size: 20px; }
  .gate-card { padding: 24px 18px; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* ── Narrow phone refinements ────────────────────── */
  .topbar-title { font-size: 14px; }
  .page { padding: 10px; }
  #page-roster .roster-card th.name-col,
  #page-roster .roster-card td.name-col {
    min-width: 90px;
    max-width: 110px;
    font-size: 11px;
  }
}

/* ── 320px emergency overrides ─────────────────────── */
@media (max-width: 340px) {
  .mobile-nav-item { font-size: 8px; letter-spacing: 0; padding: 3px 0; }
  .mnav-icon { font-size: 16px; }
  #mobile-nav { height: 54px; }
  #page-roster .roster-card td.name-col { min-width: 80px; max-width: 95px; }
}

/* ── v3.5.46 Timesheets phone card-stack view (≤768px) ── */
@media (max-width: 768px) {
  /* Hide desktop table */
  #page-timesheets .ts-table-scroll,
  #page-timesheets .roster-card > .table-scroll { display: none !important; }

  .ts-mlist { padding: 0; }
  .ts-mgroup {
    display: flex; align-items: center; gap: 6px; padding: 10px 14px;
    margin: 8px 0 2px; border-left: 4px solid var(--navy-3);
    font-size: 12px; font-weight: 700; color: var(--navy);
    text-transform: uppercase; letter-spacing: .6px;
    user-select: none; background: var(--surface-2);
  }
  .ts-mcard {
    background: #fff; border: 1px solid var(--border);
    border-radius: 10px; margin: 6px 0; overflow: hidden;
  }
  .ts-mcard-status-complete { border-left: 4px solid var(--green); }
  .ts-mcard-status-partial  { border-left: 4px solid var(--red); }
  .ts-mcard-status-empty    { border-left: 4px solid var(--ink-4); }
  .ts-mcard-status-leave    { border-left: 4px solid var(--purple); background: rgba(124,119,185,.04); }
  .ts-mcard-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px; cursor: pointer; user-select: none;
  }
  .ts-mcard-chev { font-size: 10px; color: var(--ink-3); flex-shrink: 0; transition: transform .15s; }
  .ts-mcard:not(.ts-mcard-collapsed) .ts-mcard-chev { transform: rotate(90deg); }
  .ts-mcard-icon { font-size: 15px; flex-shrink: 0; }
  .ts-mcard-name { font-size: 13px; font-weight: 700; color: var(--navy); flex: 1; min-width: 0; }
  .ts-mcard-badge { font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
  .ts-mbadge-app { color: var(--purple); background: var(--purple-lt); }
  .ts-mbadge-de  { color: #2563eb; background: #EAF5FB; }
  .ts-mbadge-lh  { color: var(--navy-3); background: var(--slate-lt); }
  .ts-mcard-statusicon { font-size: 14px; font-weight: 700; flex-shrink: 0; }
  .ts-mcard-statusicon.complete { color: var(--green); }
  .ts-mcard-statusicon.partial  { color: var(--red); }
  .ts-mcard-statusicon.empty    { color: var(--ink-4); }
  .ts-mcard-statusicon.leave    { color: var(--purple); }
  .ts-mcard-total { font-size: 13px; font-weight: 700; flex-shrink: 0; min-width: 32px; text-align: right; }
  .ts-mcard-total.green { color: var(--green); }
  .ts-mcard-total.red   { color: var(--red); }
  .ts-mcard-total.empty { color: var(--ink-4); }
  .ts-mcard-collapsed .ts-mcard-body { display: none; }
  .ts-mcard-body { padding: 0 14px 14px; }
  .ts-mcard-meta {
    display: flex; align-items: center; gap: 8px; padding: 6px 0 10px;
    border-bottom: 1px solid var(--border); margin-bottom: 8px;
    font-size: 11px; color: var(--ink-2);
  }
  .ts-mcard-copylast {
    background: none; border: 1px solid var(--border); border-radius: 5px;
    font-size: 11px; color: var(--navy); padding: 3px 9px;
    cursor: pointer; font-family: inherit; font-weight: 600;
  }
  .ts-mcard-copylast:disabled { opacity: .45; cursor: not-allowed; }
  .ts-mfillweek {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 12px; margin-bottom: 10px;
    background: #EAF5FB; border: 1px solid #b3daf4; border-radius: 8px;
    font-size: 12px; color: var(--navy);
  }
  .ts-mfillweek-text { flex: 1; min-width: 0; }
  .ts-mfillweek-icon { font-size: 14px; margin-right: 4px; }
  .ts-mfillweek-job  { font-weight: 700; }
  .ts-mfillweek-btn  {
    background: #3DA8D8; color: #fff; border: none; border-radius: 7px;
    padding: 7px 14px; font-size: 12px; font-weight: 700;
    cursor: pointer; font-family: inherit; flex-shrink: 0;
  }
  .ts-mday {
    border: 1px solid var(--border); border-radius: 8px; margin: 5px 0; overflow: hidden;
  }
  .ts-mday-today { border-color: #3DA8D8; }
  .ts-mday-muted { background: var(--surface-2); opacity: .7; }
  .ts-mday-head {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; cursor: pointer; user-select: none;
  }
  .ts-mday-label { font-size: 12px; font-weight: 700; color: var(--navy); min-width: 28px; }
  .ts-mday-date  { font-size: 11px; color: var(--ink-3); }
  .ts-mday-spacer { flex: 1; }
  .ts-mday-mutepill {
    font-size: 11px; font-weight: 600; color: var(--purple);
    background: var(--purple-lt); padding: 2px 7px; border-radius: 4px;
  }
  .ts-mday-status { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; }
  .ts-mday-status.done  { color: var(--green); background: rgba(22,163,74,.08); }
  .ts-mday-status.empty { color: var(--ink-3); background: var(--surface-2); }
  .ts-mday-collapsed .ts-mday-body,
  .ts-mday-collapsed .ts-mday-summary { display: none; }
  .ts-mday-summary { padding: 0 12px 6px; font-size: 12px; color: var(--ink-2); }
  .ts-mday-summary-job  { font-weight: 600; color: var(--navy); }
  .ts-mday-summary-hint { opacity: .55; }
  .ts-mday-body { padding: 0 12px 12px; }
  .ts-minput-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 10px; }
  .ts-minput-row + .ts-minput-row { margin-top: 8px; }
  .ts-minput-label {
    display: block; font-size: 10px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px;
  }
  .ts-minput-jobwrap { flex: 1; min-width: 0; }
  .ts-minput-hrswrap { width: 68px; flex-shrink: 0; }
  .ts-minput-field {
    width: 100%; padding: 10px 12px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--navy);
    font-family: inherit; box-sizing: border-box;
  }
  .ts-minput-field:focus { border-color: #3DA8D8; outline: none; }
  .ts-minput-hrs { text-align: center; }
  .ts-mday-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
  .ts-msplit-btn {
    background: none; border: 1px solid var(--border); border-radius: 7px;
    font-size: 12px; color: var(--ink-2); padding: 6px 12px;
    cursor: pointer; font-family: inherit;
  }
  .ts-msplit-btn.active { border-color: var(--red); color: var(--red); }
  .ts-mrepeat-btn {
    background: none; border: 1px solid var(--border); border-radius: 7px;
    font-size: 12px; color: var(--navy); padding: 6px 12px;
    cursor: pointer; font-family: inherit; font-weight: 600;
  }
  .sched-bubble {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px;
    color: var(--ink-2); background: var(--surface-2); border-radius: 5px;
    padding: 2px 7px; max-width: 120px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .sched-bubble-freetext { color: var(--ink-3); font-style: italic; }
  .sched-bubble-icon { font-size: 13px; flex-shrink: 0; }
  .sched-bubble-text { overflow: hidden; text-overflow: ellipsis; }
}
