/*
 * MMR Crew Supervisor PWA - Styles
 * Brand tokens mirror the main site (/Users/melbournemaderoofing/Desktop/site/style.css)
 * and the mockup (/Users/melbournemaderoofing/Desktop/site/mmr-pwa-mockup.html)
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #0a0b0d;
  --bg-2: #101218;
  --surface: #14161e;
  --surface-2: #1b1e28;
  --surface-3: #252936;
  --border: #2a2d3a;
  --gold: #c8933a;
  --gold-bright: #e0a84a;
  --gold-soft: rgba(200, 147, 58, 0.12);
  --gold-border: rgba(200, 147, 58, 0.3);
  --cream: #f4ede1;
  --cream-dim: rgba(244, 237, 225, 0.7);
  --text: #f4ede1;
  --text-dim: #8a8c96;
  --text-faint: #5a5c66;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 8px 24px rgba(200, 147, 58, 0.35);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Touch targets - minimum 44px for iOS accessibility */
  --tap-min: 44px;
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.4;
  font-size: 16px;
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: none;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PROGRESS BAR (top of screen)
   ============================================================ */
.progress-wrap {
  margin-bottom: var(--space-4);
}

.progress-track {
  height: 4px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.step-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: var(--space-2);
}

.step-label .back-btn {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  padding: 2px 0;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.step-label .back-btn:hover {
  color: var(--cream);
}

/* ============================================================
   HEADINGS
   ============================================================ */
.screen-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--cream);
  letter-spacing: -0.8px;
  line-height: 1.1;
  margin-bottom: var(--space-2);
}

.screen-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: var(--space-6);
  line-height: 1.5;
}

/* ============================================================
   FIELDS
   ============================================================ */
.field {
  margin-bottom: var(--space-5);
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
  text-transform: uppercase;
}

.field-required::after {
  content: " *";
  color: var(--gold);
}

.field-hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: var(--space-2);
  line-height: 1.4;
}

/* Text inputs */
.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-4);
  color: var(--cream);
  font-size: 16px; /* 16px prevents iOS zoom on focus */
  font-weight: 500;
  min-height: var(--tap-min);
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--surface-2);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

/* Select with custom arrow */
.select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%23c8933a' d='M6 8L0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* Honeypot - visually hidden but not aria-hidden */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   TIME / DATE DISPLAY
   ============================================================ */
.time-display {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  min-height: var(--tap-min);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.time-display .num {
  color: var(--cream);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.time-display .label {
  color: var(--text-dim);
  font-size: 10px;
  margin-top: 2px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.time-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* ============================================================
   CHIPS (multi-select buttons)
   ============================================================ */
.chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.chip {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.chip:active {
  transform: scale(0.97);
}

.chip.selected {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.chip.selected.good {
  background: rgba(74, 222, 128, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.chip.selected.bad {
  background: rgba(248, 113, 113, 0.12);
  border-color: var(--error);
  color: var(--error);
}

.chip.selected.warn {
  background: rgba(251, 191, 36, 0.12);
  border-color: var(--warning);
  color: var(--warning);
}

/* Horizontal scroll for chip rows on small screens */
.chips.scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.chips.scroll::-webkit-scrollbar {
  display: none;
}

.chips.scroll .chip {
  flex: 0 0 auto;
}

/* Multi-column chip grid for long option lists */
.chips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.chips-grid .chip {
  flex: none;
}

/* ============================================================
   STEPPER
   ============================================================ */
.stepper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  justify-content: space-between;
  min-height: var(--tap-min);
}

.stepper button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--cream);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper button:active {
  background: var(--gold-soft);
}

.stepper .count {
  color: var(--cream);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  min-height: 52px;
  transition: transform 0.1s, box-shadow 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: var(--bg);
  box-shadow: var(--shadow-gold);
}

.btn-gold:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--cream);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn-full {
  width: 100%;
}

.btn .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Push button to bottom of flex container */
.btn-bottom {
  margin-top: auto;
}

/* ============================================================
   PHOTO UPLOADER
   ============================================================ */
.photo-upload {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.photo-upload:active {
  background: var(--surface-2);
  border-color: var(--gold);
}

.photo-upload .cam-icon {
  width: 40px;
  height: 40px;
  color: var(--gold);
  margin-bottom: var(--space-2);
}

.photo-upload .label {
  color: var(--cream);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.photo-upload .sub {
  color: var(--text-dim);
  font-size: 11px;
}

.photo-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.photo-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: var(--cream);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.photo-preview .gps-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  backdrop-filter: blur(4px);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

.card-selected {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.card-compact {
  padding: var(--space-3);
}

.job-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: all 0.15s;
}

.job-card:active {
  transform: scale(0.98);
}

.job-card .radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-dim);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.job-card.card-selected .radio {
  border-color: var(--gold);
  background: var(--gold);
}

.job-card.card-selected .radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--bg);
  border-radius: 50%;
}

.job-info {
  flex: 1;
  min-width: 0;
}

.job-num {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.job-card.card-selected .job-num {
  color: var(--gold);
}

.job-addr {
  font-size: 14px;
  color: var(--cream);
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================================
   HEADER / GREETING (Home screen)
   ============================================================ */
.home-header {
  margin-bottom: var(--space-6);
}

.home-greeting {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.home-name {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1.2px;
  line-height: 1;
  background: linear-gradient(135deg, var(--gold-bright), var(--cream));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.home-date {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: var(--space-2);
  font-weight: 500;
}

.section-label {
  font-size: 10px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}

/* ============================================================
   SUCCESS SCREEN
   ============================================================ */
.success-screen {
  align-items: center;
  text-align: center;
  justify-content: center;
}

.check-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200, 147, 58, 0.25) 0%, transparent 65%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
  animation: ringPulse 2s ease-out;
}

@keyframes ringPulse {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.check-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 36px rgba(200, 147, 58, 0.5);
}

.check-mark {
  color: var(--bg);
  font-size: 44px;
  font-weight: 900;
  margin-top: -4px;
}

.success-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--cream);
  letter-spacing: -1px;
  margin-bottom: var(--space-2);
}

.success-sub {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: var(--space-6);
  max-width: 280px;
}

.notify-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-align: left;
}

.notify-card .ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notify-card .txt {
  font-size: 13px;
  color: var(--cream);
  font-weight: 600;
  line-height: 1.35;
}

.notify-card .txt .muted {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: var(--success);
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-top: var(--space-5);
}

.sync-indicator.pending {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.sync-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   OFFLINE BANNER
   ============================================================ */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning);
  color: var(--bg);
  padding: 8px var(--space-4);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  z-index: 100;
  transform: translateY(-100%);
  transition: transform 0.3s;
  padding-top: calc(8px + env(safe-area-inset-top));
}

.offline-banner.show {
  transform: translateY(0);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-3);
  border: 1px solid var(--gold-border);
  color: var(--cream);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-width: 90vw;
  text-align: center;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(10, 11, 13, 0.3);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-loading .spinner {
  margin-right: 8px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-4);
  z-index: 300;
  color: var(--cream);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.loading-overlay .spinner {
  width: 40px;
  height: 40px;
  border-width: 3px;
  border-color: var(--gold-soft);
  border-top-color: var(--gold);
}

/* ============================================================
   HOME INTRO (first launch)
   ============================================================ */
.intro {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.intro .logo {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: linear-gradient(135deg, #0a0b0d 0%, #1c1511 100%);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-6);
  box-shadow: 0 12px 36px rgba(200, 147, 58, 0.45);
}

.intro .logo-text {
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
}

.intro h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--cream);
  letter-spacing: -1px;
  margin-bottom: var(--space-3);
}

.intro p {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 280px;
  margin: 0 auto var(--space-8);
  line-height: 1.5;
}

/* ============================================================
   SUMMARY TABLE (shown before submit)
   ============================================================ */
.summary-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-4);
}

.summary-row {
  display: flex;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  gap: var(--space-4);
  align-items: flex-start;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row .lbl {
  color: var(--text-dim);
  font-weight: 600;
  flex-shrink: 0;
  width: 40%;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.4px;
  padding-top: 2px;
}

.summary-row .val {
  color: var(--cream);
  font-weight: 600;
  flex: 1;
  word-wrap: break-word;
  word-break: break-word;
}

.summary-row .val em {
  color: var(--text-faint);
  font-style: normal;
}

.photo-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.photo-count .num {
  background: var(--gold-soft);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 380px) {
  .screen {
    padding: var(--space-5) var(--space-4);
  }

  .screen-title {
    font-size: 24px;
  }
}
