/* TrailSense: Premium Deep Forest Design System
   High-aesthetic, tactile, responsive UI optimized for outdoor sunlight & dark canopy */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-deep: #050d08;
  --bg-forest: #08150e;
  --bg-card: rgba(13, 29, 20, 0.72);
  --bg-card-hover: rgba(19, 43, 30, 0.88);
  --border-glass: rgba(52, 211, 153, 0.18);
  --border-bright: rgba(52, 211, 153, 0.45);
  
  --emerald-glow: #10b981;
  --emerald-bright: #34d399;
  --emerald-dark: #064e3b;
  --moss-accent: #84cc16;
  --amber-warm: #f59e0b;
  --crimson-soft: #ef4444;
  
  --text-main: #f1f5f3;
  --text-muted: #94a39b;
  --text-dim: #5c6e64;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 28px rgba(16, 185, 129, 0.16);
  --shadow-subtle: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-deep);
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(132, 204, 22, 0.06) 0%, transparent 45%),
    linear-gradient(180deg, #050d08 0%, #08160e 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Base Container */
.app-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 20px 48px;
}

/* Header & Offline Banner */
header {
  margin-bottom: 20px;
}

.offline-pill-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(8, 21, 14, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  margin-bottom: 16px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--emerald-bright);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  background: var(--emerald-bright);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--emerald-bright);
  animation: pulse-ring 2s infinite ease-in-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.screen-timer-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.screen-timer-count {
  color: var(--amber-warm);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* Branding */
.brand-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.brand-titles h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  background: linear-gradient(135deg, #ffffff 30%, #a7f3d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.brand-tagline {
  color: var(--emerald-bright);
  font-weight: 500;
  font-size: 1rem;
  margin-top: 4px;
}

.brand-philosophy {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 580px;
  margin-top: 6px;
}

/* Quick Action / Screen Down Prompt */
.screen-down-nudge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(132, 204, 22, 0.08));
  border: 1px solid var(--border-glass);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-main);
  box-shadow: var(--shadow-glow);
}

.nudge-icon {
  font-size: 1.4rem;
}

/* Tabs Navigation */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: rgba(8, 22, 15, 0.6);
  backdrop-filter: blur(10px);
  padding: 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 140px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--emerald-dark) 0%, #0f3d28 100%);
  color: #a7f3d0;
  border: 1px solid var(--border-bright);
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.22);
}

/* Tab Panels */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

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

/* Glass Card */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 24px;
  position: relative;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-badge {
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-bright);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Audio Spectrogram Stage */
.spectrogram-box {
  width: 100%;
  height: 180px;
  background: #040a06;
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
}

#spectrogramCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.spectrogram-overlay-legend {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}

/* Mic / Control Buttons */
.controls-cluster {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #041209;
  border: none;
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Outfit', sans-serif;
  padding: 13px 26px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
  font-weight: 600;
  font-size: 0.92rem;
  font-family: 'Outfit', sans-serif;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-bright);
}

/* Sample Quick-Test Grid */
.samples-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.sample-card {
  background: rgba(9, 23, 16, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.sample-card:hover {
  border-color: var(--emerald-bright);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.sample-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.sample-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sample-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--emerald-bright);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  width: fit-content;
}

/* Camera & Vision Preview */
.vision-stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .vision-stage {
    grid-template-columns: 1fr 1fr;
  }
}

.preview-frame {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #040a06;
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-frame img, .preview-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-hud-overlay {
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(52, 211, 153, 0.4);
  border-radius: var(--radius-sm);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--emerald-bright);
}

.hud-corners::before {
  content: "TARGET: FLORA / CANOPY";
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 3px;
}

.hud-corners::after {
  content: "AI MODEL: LOCAL OFFLINE";
  float: right;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Identification Result Card */
.result-card {
  background: linear-gradient(135deg, rgba(16, 40, 28, 0.92) 0%, rgba(8, 23, 16, 0.95) 100%);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  display: none;
  animation: slideUp 0.35s ease-out;
  margin-top: 20px;
}

.result-card.visible {
  display: block;
}

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

.result-headline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.result-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
}

.result-scientific {
  font-style: italic;
  font-size: 0.9rem;
  color: var(--emerald-bright);
  margin-top: 2px;
}

.confidence-chip {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--emerald-bright);
  color: #a7f3d0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.field-notes-box {
  background: rgba(5, 14, 9, 0.6);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-row {
  display: flex;
  gap: 8px;
}

.field-label {
  color: var(--text-muted);
  font-weight: 600;
  min-width: 110px;
}

.field-value {
  color: var(--text-main);
}

.touch-grass-card {
  background: linear-gradient(135deg, rgba(132, 204, 22, 0.15), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(132, 204, 22, 0.35);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.touch-grass-icon {
  font-size: 1.8rem;
}

.touch-grass-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #bef264;
  margin-bottom: 3px;
}

.touch-grass-desc {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.45;
}

/* Pocket Screen Countdown Modal/Overlay */
.pocket-banner {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Journal / Sightings List */
.journal-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.88rem;
}

.journal-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-glass);
}

.journal-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.journal-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Sensory Quest Mode Cards */
.quest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.quest-card {
  background: rgba(9, 23, 16, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: all 0.2s ease;
}

.quest-card:hover {
  border-color: var(--emerald-bright);
  background: var(--bg-card-hover);
}

.quest-status {
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
}

.quest-status.todo {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber-warm);
}

.quest-status.done {
  background: rgba(16, 185, 129, 0.2);
  color: var(--emerald-bright);
}

.quest-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.quest-instruction {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Footer & Tech Breakdown */
footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-glass);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.tech-badges-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.tech-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .app-container {
    padding: 12px 14px 40px;
  }
  .controls-cluster {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary, .btn-secondary {
    justify-content: center;
  }
  .offline-pill-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
