/* ═══════════════════════════════════════════════════════════
   SPRUNG FIELD PORTAL — Global Stylesheet
   Shared resets, variables, and mobile overflow prevention.
   Each page keeps its own inline <style> for page-specific rules.
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables (superset — pages may override/extend) ── */
:root {
  --bg:      #080808;
  --surface: #0f0f0f;
  --surface2:#141414;
  --border:  rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text:    #e8e8e8;
  --muted:   rgba(255,255,255,0.38);
  --muted2:  rgba(255,255,255,0.55);
  --red:     #C0282F;
  --green:   #4ADE80;
  --blue:    #3B82F6;
  --amber:   #F59E0B;
  --purple:  #A78BFA;
  --orange:  #E87B40;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Overflow prevention (the main mobile fix) ─────────── */
html {
  overflow-x: hidden;
}
body {
  overflow-x: hidden;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

/* ── Mobile-safe element defaults ──────────────────────── */
img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

table {
  max-width: 100%;
}

input, select, textarea, button {
  max-width: 100%;
}

pre, code {
  overflow-x: auto;
  max-width: 100%;
}

/* ── Scrollbar (dark theme) ────────────────────────────── */
/* 12px gives a comfortable grab target on desktop while staying out of the
   way; mobile devices auto-hide native scrollbars regardless. Inner
   horizontal-scroll strips that should remain hidden (wizard tabs, photo
   strips, jobs bar) override this in their own component CSS. */
::-webkit-scrollbar         { width: 12px; height: 12px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: rgba(255,255,255,0.18); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); background-clip: padding-box; }
html { scrollbar-width: auto; scrollbar-color: rgba(255,255,255,0.18) transparent; }

/* ── Global text overflow safety ──────────────────────── */
.container,
.jobber-panel,
.context-card,
.job-row,
.jobber-results,
.photo-feed,
.photo-feed-card {
  overflow-x: hidden;
  max-width: 100%;
}

.job-title,
.job-meta,
.context-value,
.context-sub,
.photo-feed-caption,
.photo-feed-extract {
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* Toast: allow wrapping on mobile */
.toast {
  max-width: calc(100vw - 32px);
  white-space: normal !important;
  word-break: break-word;
}

/* ── iOS auto-zoom prevention ─────────────────────────── */
/* iOS Safari zooms in on inputs with font-size < 16px,    */
/* causing the page to shift right. Force 16px on mobile.  */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ── Mobile topbar & layout overrides ─────────────────── */
@media (max-width: 600px) {
  /* Override calc()-based centering padding that breaks on narrow screens */
  .topbar {
    padding-left: 10px !important;
    padding-right: 10px !important;
    gap: 8px !important;
  }

  /* Prevent topbar children from forcing overflow */
  .topbar-right,
  .topbar-left {
    min-width: 0 !important;
    flex-shrink: 1;
  }

  /* Topbar buttons: allow text to shrink */
  .topbar-btn,
  .back-btn {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }

  /* Container: tighter padding on mobile */
  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Popup/dropdown menus: never wider than viewport */
  [style*="min-width:200px"],
  [style*="min-width: 200px"],
  [style*="min-width:170px"],
  [style*="min-width: 170px"] {
    min-width: min(200px, 88vw) !important;
    max-width: 92vw !important;
  }
}

/* ── Tables: always scrollable when overflowing ───────── */
.table-wrap,
.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* ── Offline queue badge ──────────────────────────────── */
.offline-queue-badge {
  position: fixed;
  bottom: 70px;
  right: 12px;
  background: var(--amber);
  color: #000;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 9999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ── Shared keyframes ──────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
