/* ═══════════════════════════════════════════════════
   SolarSurvey — Industrial Field UI
   Mobile-first, high-contrast, battery-conscious
   ═══════════════════════════════════════════════════ */
/* ─── DESIGN TOKENS ─── */
:root {
  /* Base palette — High-Contrast Daylight (Sun-Glare Resistant) */
  --bg-primary:    #ffffff;
  --bg-secondary:  #f3f4f6;
  --bg-card:       #ffffff;
  --bg-elevated:   #ffffff;
  --bg-input:      #ffffff;

  /* Text — Deep black for maximum readability */
  --text-primary:  #030712; 
  --text-secondary:#374151;
  --text-muted:    #6b7280;

  /* Accent: Safety Orange (Darkened slightly to pop on white) */
  --amber:         #ea580c; 
  --amber-dim:     #c2410c;
  --amber-glow:    rgba(234, 88, 12, 0.15);

  /* Functional colors (Deepened for white backgrounds) */
  --green:         #059669;
  --green-dim:     rgba(5, 150, 105, 0.15);
  --red:           #dc2626;
  --red-dim:       rgba(220, 38, 38, 0.15);
  --blue:          #2563eb;
  --blue-dim:      rgba(37, 99, 235, 0.12);

  /* Borders */
  --border:        #d1d5db;
  --border-focus:  var(--amber);

  /* Spacing */
  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  32px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Z-layers */
  --z-status:    100;
  --z-capture:   50;
  --z-toast:     200;
  --z-overlay:   150;

  /* Safe areas */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── UTILITIES ─── */
.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
.accent { color: var(--amber); }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   STATUS BAR
   ═══════════════════════════════════════════ */
#status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-status);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) var(--gap-md) 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  min-width: 90px;
}

.status-right { justify-content: flex-end; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}

.dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px rgba(248,113,113,0.4);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.app-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--text-primary);
}

#sync-badge {
  color: var(--text-muted);
  font-size: 10px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}

.icon-btn:active { color: var(--amber); background: var(--amber-glow); }

/* ═══════════════════════════════════════════
   VIEWS
   ═══════════════════════════════════════════ */
#app-main {
  padding-top: calc(var(--safe-top) + 56px);
  padding-bottom: calc(var(--safe-bottom) + 24px);
  min-height: 100dvh;
}

.view {
  display: none;
  padding: var(--gap-md);
  animation: fadeIn 0.25s ease;
}

.view.active { display: block; }

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

.view-header {
  margin-bottom: var(--gap-lg);
}

.view-header h1 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 24px;
  color: var(--text-primary);
  line-height: 1.2;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

/* ─── Buttons ─── */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-sm);
}

.btn-primary {
  background: var(--amber);
  color: #0a0f14;
}

.btn-primary:active { background: #d9911e; transform: scale(0.97); }
.btn-primary:disabled { background: var(--text-muted); color: var(--bg-primary); cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:active { border-color: var(--amber); color: var(--amber); }
.btn-wide { width: 100%; }

/* ─── RUGGED FIELD NAVIGATION (Thumb-Zone) ─── */
.btn-back {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 20px;
  border-radius: var(--radius-md);
  margin-bottom: var(--gap-lg);
  width: 100%;
  height: 60px; /* Massive touch target for gloved/sweaty hands */
  transition: all 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn-back:active { 
  border-color: var(--amber); 
  background: var(--bg-elevated);
  transform: scale(0.98);
}

.btn-back svg {
  width: 24px;
  height: 24px;
  color: var(--amber); /* High contrast accent so it's visible in sun glare */
}
/* ═══════════════════════════════════════════
   PROJECT CARDS
   ═══════════════════════════════════════════ */
.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-lg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--amber);
  border-radius: 4px 0 0 4px;
}

.project-card:active {
  border-color: var(--amber);
  transform: scale(0.98);
}

.project-card h3 {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.project-card .address {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: var(--gap-sm);
}

.project-card .meta {
  display: flex;
  gap: var(--gap-md);
}

.project-card .meta-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.empty-state {
  text-align: center;
  padding: var(--gap-xl) var(--gap-md);
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: var(--gap-md); }
.empty-state p { margin-bottom: var(--gap-lg); font-size: 14px; }

/* ═══════════════════════════════════════════
   SURVEY CATEGORY GRID
   ═══════════════════════════════════════════ */
.category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-md);
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-md) var(--gap-lg);
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  min-height: 72px;
}

.category-card:active {
  transform: scale(0.98);
  border-color: var(--amber);
}

.category-card.completed {
  border-color: var(--green);
  background: var(--green-dim);
}

.category-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--amber-glow);
  color: var(--amber);
}

.category-card.completed .category-icon {
  background: var(--green-dim);
  color: var(--green);
}

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

.category-info h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.category-info p {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  color: var(--text-muted);
  flex-shrink: 0;
}

.category-card.completed .category-badge {
  background: var(--green);
  color: #0a0f14;
}

/* ═══════════════════════════════════════════
   PROGRESS BAR & SUBMIT
   ═══════════════════════════════════════════ */
.submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-capture);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.progress-track {
  height: 3px;
  background: var(--bg-primary);
}

.progress-fill {
  height: 100%;
  background: var(--amber);
  transition: width 0.4s ease;
}

.submit-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-sm) var(--gap-md);
}

/* ═══════════════════════════════════════════
   CAMERA / CAPTURE VIEW
   ═══════════════════════════════════════════ */
#view-capture {
  padding: 0;
}

.capture-header {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.capture-header h2 {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--amber-glow);
  color: var(--amber);
  padding: 2px 8px;
  border-radius: 99px;
}

/* Viewfinder */
.viewfinder-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  overflow: hidden;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.crosshair {
  position: absolute;
  background: rgba(245, 166, 35, 0.2);
}

.crosshair-h {
  top: 50%;
  left: 10%;
  right: 10%;
  height: 1px;
  transform: translateY(-50%);
}

.crosshair-v {
  left: 50%;
  top: 10%;
  bottom: 10%;
  width: 1px;
  transform: translateX(-50%);
}

.validation-badge {
  position: absolute;
  top: var(--gap-md);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 15, 20, 0.85);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  transition: opacity 0.3s;
  white-space: nowrap;
}

.validation-badge.pass { border-color: var(--green); color: var(--green); }
.validation-badge.fail { border-color: var(--red); color: var(--red); }

/* Capture controls */
.capture-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-xl);
  padding: var(--gap-md) 0;
  background: var(--bg-secondary);
}

.icon-btn-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn-lg:active { border-color: var(--amber); color: var(--amber); }

.shutter-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid var(--text-primary);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  position: relative;
}

.shutter-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--text-primary);
  transition: all 0.15s;
}

.shutter-btn:active .shutter-ring {
  transform: scale(0.85);
  background: var(--amber);
}

/* Recording state */
.icon-btn-lg[data-recording="true"] {
  border-color: var(--red);
  color: var(--red);
  animation: pulse-record 1s infinite;
}

@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}

/* Thumbnails */
.thumbnail-strip {
  display: flex;
  gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap-md);
  overflow-x: auto;
  background: var(--bg-primary);
  min-height: 72px;
  align-items: center;
}

.thumbnail-strip:empty::after {
  content: 'No captures yet';
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: center;
}

.thumb {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--border);
  position: relative;
  cursor: pointer;
}

.thumb img, .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb .thumb-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.9);
  border: none;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.thumb.pass { border-color: var(--green); }
.thumb.fail { border-color: var(--red); }

.thumb .thumb-type-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-family: var(--font-mono);
  font-size: 8px;
  background: rgba(10,15,20,0.8);
  color: var(--text-secondary);
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* Notes */
.capture-notes {
  padding: var(--gap-sm) var(--gap-md);
  background: var(--bg-secondary);
}

.capture-notes label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.capture-notes textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: var(--gap-sm);
  resize: none;
  transition: border-color 0.2s;
}

.capture-notes textarea:focus {
  outline: none;
  border-color: var(--amber);
}

.capture-actions {
  padding: var(--gap-md);
  padding-bottom: calc(var(--gap-md) + var(--safe-bottom));
  background: var(--bg-secondary);
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: var(--gap-md);
  right: var(--gap-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px var(--gap-md);
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: auto;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--amber); }

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

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

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (min-width: 480px) {
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  #app-main {
    max-width: 640px;
    margin: 0 auto;
  }
}
/* ─── FIXED CAPTURE ACTIONS (Always at the thumb) ─── */
.capture-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--gap-md);
  padding-bottom: calc(var(--gap-md) + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: var(--z-capture);
}

/* Add padding to the notes section so it isn't hidden by the new fixed button */
.capture-notes {
  padding-bottom: 100px; 
}
