/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — v2.1.0 audit
   Small mobile: ≤480px · Large mobile: ≤640px
══════════════════════════════════════════════════════════════ */

/* ── AUDIT 1 — Header ───────────────────────────────────────── */
@media (max-width: 480px) {
  .rl-hero { padding: env(safe-area-inset-top) 12px 0 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .rl-hero h1 { font-size: 1.2rem; margin: 0; }
  .rl-hero .subtitle { display: none; }
  /* Override absolute positioning of button group so flex layout works */
  .rl-hero > .no-print[style*="position:absolute"] {
    position: static !important; top: auto !important; right: auto !important;
    flex-shrink: 0; display: flex; gap: 4px;
  }
  /* Hide server sync status on mobile */
  #serverSyncStatus { display: none; }
}

/* ── AUDIT 2 — Tab bar ──────────────────────────────────────── */
@media (max-width: 480px) {
  .rl-tabbar { display: flex; flex-wrap: nowrap; }
}

/* ── AUDIT 3 — This Week tab ────────────────────────────────── */
@media (max-width: 640px) {
  #taskTypeFilterRow {
    overflow-x: auto; flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch; padding-bottom: 4px;
  }
  #taskTypeFilterRow .ttf-btn { flex-shrink: 0; }
}
@media (max-width: 480px) {
  .scope-btn { font-size: 0.7rem; padding: 0.3rem 0.5rem; }
}

/* ── AUDIT 4 — Season tab (Gantt) ───────────────────────────── */
@media (max-width: 640px) {
  #seasonGanttContainer { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .gantt-label { width: 120px; font-size: 0.68rem; }
  #tab-season > .flex { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
}

/* ── C1-C8 Season Gantt redesign ─────────────────────────────── */
.sg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FAF7F2;
  border-bottom: 1px solid var(--border-rule);
  padding: 10px 24px;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 -1.25rem 0.75rem;
}
.sg-expand-link {
  font-size: 11px;
  color: var(--ink);
  opacity: 0.45;
  cursor: pointer;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--f-body);
  line-height: 1;
}
.sg-expand-link:hover { opacity: 0.8; }
.sg-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-tan);
  color: var(--ink);
  background: #FAF7F2;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--f-body);
}
.sg-pill.sg-pill-active {
  background: #2C3A1E;
  color: #FAF7F2;
  border-color: #2C3A1E;
}
.sg-bar { opacity: 0.95; transition: opacity 0.12s; display:flex; align-items:center; justify-content:center; }
.sg-bar:hover { opacity: 1; }
/* v3.38.31 — planted-state visual: small ✓ chip at the left edge of the bar
   and a slightly stronger inset ring so the bar reads as "this slot is in the
   ground" vs "still scheduled". */
.sg-bar-planted { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.45); }
:root.dark .sg-bar-planted { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.32); }
.sg-bar-planted-mark {
  display:inline-flex; align-items:center; justify-content:center;
  width:14px; height:14px;
  margin-left:5px; flex-shrink:0;
  background:rgba(255,255,255,0.55); color:#1A1A1A;
  border-radius:50%;
  font-size:9px; font-weight:800; line-height:1;
}
:root.dark .sg-bar-planted-mark { background:rgba(255,255,255,0.78); color:#1A1A1A; }
.sg-bed-row { display:flex; align-items:center; margin-bottom:7px; min-height:28px; border-radius:2px; }
.sg-bed-row:hover { background: rgba(44,58,30,0.03); }

/* ── AUDIT 5 — My Crops tab ─────────────────────────────────── */
@media (max-width: 640px) {
  #libScheduleView { grid-template-columns: 1fr !important; }
  #tab-mycrops > .no-print[style*="display:flex"] {
    overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px;
  }
  #tab-mycrops > .no-print[style*="display:flex"] > * { flex-shrink: 0; }
  .ll-row { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  #libSearch { width: 100%; box-sizing: border-box; }
}

/* ── AUDIT 6 — Beds tab ─────────────────────────────────────── */
@media (max-width: 640px) {
  /* Hide low-priority columns: L(ft)=4, Rotation=5, Bed Notes=6, Slot Notes=10 */
  #bedsContainer th:nth-child(4),
  #bedsContainer td:nth-child(4),
  #bedsContainer th:nth-child(5),
  #bedsContainer td:nth-child(5),
  #bedsContainer th:nth-child(6),
  #bedsContainer td:nth-child(6),
  #bedsContainer th:nth-child(10),
  #bedsContainer td:nth-child(10) { display: none; }
}

/* ── AUDIT 7 — Export tab ───────────────────────────────────── */
@media (max-width: 640px) {
  #tab-export > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  #tab-export > div[style*="display:flex"] { flex-wrap: wrap; }
  #tab-export > div[style*="display:flex"] > .btn { flex: 1; min-width: 120px; }
}

/* ── AUDIT 8 — Nursery drawer / allocation modal ────────────── */
@media (max-width: 640px) {
  #allocationModal > div,
  #nurseryModal > div {
    max-height: 88dvh; overflow-y: auto;
    border-radius: 16px 16px 0 0;
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; max-width: 100%;
  }
}
@media (max-width: 480px) {
  #nurseryAddForm input,
  #nurseryAddForm select,
  #nurseryAddForm textarea { width: 100%; box-sizing: border-box; }
}

/* ── AUDIT 9 — Settings modal ───────────────────────────────── */
@media (max-width: 640px) {
  .rl-settings-overlay { align-items: flex-end !important; }
  .rl-settings-modal {
    border-radius: 16px 16px 0 0 !important;
    max-height: 88dvh !important; overflow-y: auto !important;
    width: 100% !important; max-width: 100% !important;
  }
}

/* ── AUDIT 10 — Slot modal cultivar tabs ────────────────────── */
@media (max-width: 480px) {
  #smTabLib, #smTabNursery, #smTabManual {
    font-size: 0.68rem !important; padding: 0.35rem 0.25rem !important;
  }
  .sm-lib-row { flex-wrap: wrap; gap: 0.25rem; }
  .sm-lib-row .sm-lib-actions { width: 100%; justify-content: flex-end; }
}

/* ── AUDIT 11 — iOS input zoom prevention (sitewide) ────────── */
@media (max-width: 640px) {
  input[type="text"], input[type="number"], input[type="date"],
  input[type="search"], select, textarea {
    font-size: 16px !important;
  }
}
@media (max-width: 480px) {
  #wizardOverlay > div { padding: 1.25rem !important; }
}

/* ── AUDIT 12 — Toast safe-area inset ───────────────────────── */
/* Applied via JS inline style — see _showToast() patch below  */

/* ── AUDIT 13 — Prevent unintended horizontal page scroll ──── */
.tab-panel { overflow-x: hidden; max-width: 100vw; }
/* Intentional scrollable areas keep their overflow-x:auto */

/* ── Feature 31 — Contextual hover tips (v3.22.0) ──────────── */
.tip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--f-body);
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  user-select: none;
  border: 1px solid var(--border-mid);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.tip-icon:hover { background: var(--green-tint); color: var(--green-text); border-color: var(--green); }
.tip-bubble {
  position: fixed;
  background: var(--bg-olive);
  color: #fff;
  font-size: 0.75rem;
  font-family: var(--f-body);
  font-weight: 400;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 5px;
  max-width: 260px;
  z-index: 10500;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  pointer-events: none;
  animation: _tipFade 0.14s ease;
}
@keyframes _tipFade { from { opacity: 0; transform: translateY(-2px); } }

/* ── AUDIT 14 — Touch target sizes ──────────────────────────── */
@media (max-width: 640px) {
  .slot-row button, .link-btn, .link-delete {
    min-height: 32px; min-width: 32px; padding: 4px 8px;
  }
  button[title="Move up"], button[title="Move down"] {
    min-height: 28px; min-width: 28px;
  }
}

/* ── Slot modal — mobile bottom sheet ──────────────────────── */
@media (max-width: 767px) {
  #slotAssignModal { padding: 0; align-items: flex-end; }
  #slotAssignModal .rl-modal {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    top: auto;
    height: 75vh;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
    width: 100%;
    max-width: 100%;
    transform: translateY(0);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  #slotAssignModal .rl-modal::before {
    content: '';
    display: block;
    width: 32px; height: 4px;
    background: var(--border-rule);
    border-radius: 99px;
    margin: 10px auto 0;
  }
}

/* ── Beds table — mobile column hiding ───────────────────── */
@media (max-width: 767px) {
  .bed-col-w, .bed-col-l, .bed-col-rotation,
  .bed-col-notes, .bed-col-plants, .bed-col-frac,
  .bed-col-slot-notes { display: none !important; }
  .bed-col-crop { font-size: 9px; }
}

/* ── Tab bar — mobile min-height ─────────────────────────── */
@media (max-width: 480px) {
  .tab-btn { min-height: 44px; }
}

