:root {
  /* ═══════════════════════════════════════════════════════════════
     GO ACTIVE UI KIT - Complete Color Palette
     ═══════════════════════════════════════════════════════════════ */

  /* Black palette */
  --black-900: #0F1221;       /* Main background */
  --black-800: #272A38;       /* Secondary background */
  --black-700: #3C3F4C;       /* Cards, elevated surfaces */
  --black-600: #5A5D6A;       /* Disabled states */

  /* Teal palette (accent) */
  --teal-900: #00FBF4;        /* Primary accent */
  --teal-800: #00D9D2;        /* Hover state */
  --teal-700: #00B8B2;        /* Active state */

  /* Neutral palette */
  --neutral-100: #FFFFFF;     /* Primary text */
  --neutral-200: #F5F5F5;     /* Bright text */
  --neutral-500: #9E9E9E;     /* Muted text */
  --neutral-800: #BDBDBD;     /* Secondary text */
  --neutral-900: #5C5C5C;     /* Disabled text */

  /* Status colors */
  --status-red: #FF4444;      /* Error, stop */
  --status-green: #00E676;    /* Success */
  --status-orange: #FF9800;   /* Warning */

  /* ═══════════════════════════════════════════════════════════════
     Typography Scale (Dela Gothic One for headings, Inter for body)
     ═══════════════════════════════════════════════════════════════ */
  --font-heading: 'Dela Gothic One', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;

  /* Font sizes from UI Kit */
  --text-h1: 34px;            /* Large heading */
  --text-h2: 28px;            /* Stats values */
  --text-h3: 20px;            /* Section titles */
  --text-h4: 17px;            /* Card titles */
  --text-h5: 15px;            /* Small headings */
  --text-body: 16px;          /* Body text */
  --text-small: 14px;         /* Small text */
  --text-caption: 13px;       /* Labels, captions */
  --text-micro: 12px;         /* Tiny text */

  /* ═══════════════════════════════════════════════════════════════
     Semantic aliases (for easier use)
     ═══════════════════════════════════════════════════════════════ */
  --bg-primary: var(--black-900);
  --bg-secondary: var(--black-800);
  --bg-card: var(--black-700);
  --text-primary: var(--neutral-100);
  --text-secondary: var(--neutral-800);
  --text-muted: var(--neutral-900);
  --accent: var(--teal-900);
  --accent-glow: rgba(0, 251, 244, 0.3);
  --danger: var(--status-red);
  --success: var(--teal-900);
  --border-color: rgba(255, 255, 255, 0.1);

  /* Telegram theme fallbacks */
  --tg-theme-bg-color: var(--black-900);
  --tg-theme-text-color: var(--neutral-100);
  --tg-theme-hint-color: var(--neutral-800);
  --tg-theme-button-color: var(--teal-900);
  --tg-theme-button-text-color: var(--black-900);
  --tg-theme-secondary-bg-color: var(--black-800);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
  position: relative;
}

/* Header - GPS status */
header {
  padding: 8px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  background: var(--bg-primary);
}

.gps-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.gps-status.active {
  color: var(--accent);
}

.gps-status.error {
  color: var(--danger);
}

.gps-icon {
  font-size: 14px;
}

#user-info {
  display: none;
}

/* Map container */
#map {
  flex: 1;
  min-height: 250px;
  background: var(--bg-primary);
  position: relative;
}

/* Stats panel - 2x2 grid */
#stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 20px 40px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.stat {
  padding: 8px 0;
}

/* Right column stats - align to right */
.stat:nth-child(2),
.stat:nth-child(4) {
  text-align: right;
}

.stat .value {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-h2);
  font-weight: 400;  /* Dela Gothic One only has 400 weight */
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat .label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-caption);
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
}

/* Controls - 3 buttons layout */
#controls {
  display: flex;
  padding: 20px 40px 32px;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: var(--bg-primary);
}

.btn {
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
  background: transparent;
}

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

/* Side buttons (camera, settings, stop) */
.btn-side {
  width: 56px;
  height: 56px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-side:hover {
  background: var(--bg-secondary);
}

.btn-side.btn-stop {
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
}

/* Main action button - large cyan circle */
.btn-main {
  width: 80px;
  height: 80px;
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 0 30px var(--accent-glow);
}

.btn-main:hover {
  box-shadow: 0 0 40px var(--accent-glow);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Status text */
#status {
  text-align: center;
  padding: 0 24px 16px;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  background: var(--bg-primary);
  min-height: 20px;
}

#status.recording {
  color: var(--accent);
  animation: pulse 1.5s infinite;
}

#status.error {
  color: var(--danger);
}

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

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal h2 {
  font-family: var(--font-body);
  font-size: var(--text-h4);
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal p {
  font-family: var(--font-body);
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-btn {
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.modal-btn-secondary {
  background: transparent;
  color: var(--accent);
}

/* Activity Complete Overlay */
.complete-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.complete-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  padding-top: 60px;
}

.complete-banner {
  background: linear-gradient(135deg, var(--accent) 0%, #00b4a0 100%);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.complete-icon {
  font-size: 24px;
}

.complete-title {
  font-family: var(--font-body);
  font-size: var(--text-h4);
  font-weight: 700;
  color: var(--bg-primary);
}

.complete-goal {
  text-align: center;
  font-size: 16px;
  color: var(--accent);
  margin-bottom: 24px;
  font-weight: 500;
}

.complete-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: auto;
}

.complete-stat {
  padding: 12px 0;
}

.complete-stat-value {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-h3);
  font-weight: 400;
  color: var(--text-primary);
}

.complete-stat-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-caption);
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.complete-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 20px;
}

.complete-btn {
  padding: 16px 24px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.complete-btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

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

/* Leaflet customizations for dark map */
.leaflet-container {
  background: var(--bg-primary) !important;
}

.leaflet-control-attribution {
  display: none !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: none !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-secondary) !important;
}

/* Current position marker - cyan glow */
.current-position-marker {
  width: 18px !important;
  height: 18px !important;
  background: var(--accent) !important;
  border: 3px solid var(--bg-primary) !important;
  border-radius: 50% !important;
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 20px var(--accent-glow) !important;
}

/* Start point marker */
.start-marker {
  width: 14px !important;
  height: 14px !important;
  background: var(--accent) !important;
  border: 2px solid var(--bg-primary) !important;
  border-radius: 50% !important;
  opacity: 0.7;
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #controls {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .complete-buttons {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}

/* Responsive adjustments */
@media (max-height: 600px) {
  #stats {
    padding: 12px 20px;
  }

  .stat .value {
    font-size: 24px;
  }

  #controls {
    padding: 12px 24px 20px;
  }

  .btn-main {
    width: 70px;
    height: 70px;
  }

  .btn-side {
    width: 50px;
    height: 50px;
  }
}

/* Location Sharing Prompt Overlay */
.location-prompt {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 25, 41, 0.95);
  backdrop-filter: blur(10px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.location-prompt-content {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border-color);
}

.location-prompt-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.location-prompt-title {
  font-family: var(--font-body);
  font-size: var(--text-h3);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.location-prompt-text {
  font-family: var(--font-body);
  font-size: var(--text-small);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  text-align: left;
}

.location-prompt-btn {
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
}

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

/* ═══════════════════════════════════════════════════════════════
   LIGHT THEME - Auto-detected from Telegram or manual toggle
   ═══════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  /* Light backgrounds */
  --black-900: #FFFFFF;       /* Main background - white */
  --black-800: #F5F5F5;       /* Secondary background */
  --black-700: #E8E8E8;       /* Cards, elevated surfaces */
  --black-600: #D0D0D0;       /* Disabled states */

  /* Teal palette - slightly darker for contrast on light */
  --teal-900: #00B8B2;        /* Primary accent (darker) */
  --teal-800: #00A09A;        /* Hover state */
  --teal-700: #008882;        /* Active state */

  /* Neutral palette - inverted for light mode */
  --neutral-100: #0F1221;     /* Primary text - dark */
  --neutral-200: #1A1D2E;     /* Bright text */
  --neutral-500: #666666;     /* Muted text */
  --neutral-800: #4A4A4A;     /* Secondary text */
  --neutral-900: #888888;     /* Disabled text */

  /* Borders for light theme */
  --border-color: rgba(0, 0, 0, 0.1);
  --accent-glow: rgba(0, 184, 178, 0.25);

  /* Telegram theme overrides */
  --tg-theme-bg-color: #FFFFFF;
  --tg-theme-text-color: #0F1221;
  --tg-theme-hint-color: #4A4A4A;
  --tg-theme-button-color: #00B8B2;
  --tg-theme-button-text-color: #FFFFFF;
  --tg-theme-secondary-bg-color: #F5F5F5;
}

/* Light theme specific overrides */
[data-theme="light"] .btn-side.btn-stop {
  background: #0F1221;
  color: #FFFFFF;
}

[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .location-prompt {
  background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .complete-banner {
  background: linear-gradient(135deg, #00B8B2 0%, #008882 100%);
}

[data-theme="light"] .complete-title {
  color: #FFFFFF;
}

[data-theme="light"] .current-position-marker {
  background: #00B8B2 !important;
  border-color: #FFFFFF !important;
  box-shadow:
    0 0 0 3px #00B8B2,
    0 0 20px rgba(0, 184, 178, 0.4) !important;
}

[data-theme="light"] .start-marker {
  background: #00B8B2 !important;
  border-color: #FFFFFF !important;
}

[data-theme="light"] .leaflet-control-zoom a {
  background: #FFFFFF !important;
  color: #0F1221 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

[data-theme="light"] .leaflet-control-zoom a:hover {
  background: #F5F5F5 !important;
}
