/* VoyaAI Brand Styles — Mobile-first */
:root {
  --color-primary:  #1B3A4B;
  --color-mid:      #385D73;
  --color-gold:     #C9A14A;
  --color-bg:       #F7F5F0;
  --color-bg-light: #EEF4F8;
  --color-text:     #2C2C2A;
  --color-success:  #4CAF50;
  --color-error:    #E53935;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
.hidden { display: none !important; }

/* === ROUTE INPUT OVERLAY === */
.route-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s, transform 0.3s;
}

.route-overlay.hidden {
  display: none !important;
}

.route-overlay-content {
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.route-logo {
  font-size: 36px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.route-subtitle {
  font-size: 14px;
  color: var(--color-gold);
  font-weight: 600;
  margin-bottom: 28px;
}

.route-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.route-input-group input,
#route-freetext {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--color-bg-light);
  border-radius: 12px;
  font-size: 16px;
  background: white;
  color: var(--color-text);
  transition: border-color 0.2s;
}

.route-input-group input:focus,
#route-freetext:focus {
  outline: none;
  border-color: var(--color-gold);
}

.route-or {
  font-size: 12px;
  color: var(--color-mid);
  margin: 8px 0;
}

.route-plan-btn {
  width: 100%;
  padding: 14px;
  background: var(--color-gold);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.2s;
}

.route-plan-btn:active { transform: scale(0.97); }
.route-plan-btn:disabled { background: #ccc; cursor: wait; }

.route-gps-btn {
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.route-gps-btn:active { transform: scale(0.97); }

.route-status {
  font-size: 13px;
  color: var(--color-mid);
  margin-top: 12px;
  min-height: 20px;
}

.route-demo {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.route-demo-label {
  font-size: 11px;
  color: var(--color-mid);
  width: 100%;
  margin-bottom: 4px;
}

.route-demo-btn {
  padding: 6px 14px;
  border: 1px solid var(--color-mid);
  background: white;
  color: var(--color-mid);
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.route-demo-btn:active { background: var(--color-bg-light); }

/* === ROUTE LOADING ANIMATION === */
.route-loading {
  margin: 20px 0 8px;
}

.road-scene {
  position: relative;
  height: 80px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, #d4edfc 0%, #e8f4ec 40%, #b8d4a3 40%, #8fbc6b 100%);
}

/* Road */
.road {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  height: 18px;
  background: #555;
  border-radius: 2px;
}

.road-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 200%;
  height: 2px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, #C9A14A 0px, #C9A14A 16px, transparent 16px, transparent 28px);
  animation: roadScroll 1.2s linear infinite;
}

@keyframes roadScroll {
  from { transform: translateY(-50%) translateX(0); }
  to { transform: translateY(-50%) translateX(28px); }
}

/* Car */
.car-anim {
  position: absolute;
  bottom: 22px;
  left: 55%;
  font-size: 26px;
  animation: carBounce 0.6s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
  z-index: 5;
}

@keyframes carBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* Scenery items floating past */
.scenery {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.scenery-item {
  position: absolute;
  font-size: 22px;
  animation: sceneryPass 6s linear infinite;
  opacity: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.s1 { top: 2px;  animation-delay: 0s; font-size: 26px; }
.s2 { top: 8px;  animation-delay: 1.2s; font-size: 20px; }
.s3 { top: 0;    animation-delay: 2.4s; font-size: 28px; }
.s4 { top: 14px; animation-delay: 3.6s; font-size: 18px; }
.s5 { top: 4px;  animation-delay: 4.8s; font-size: 22px; }

@keyframes sceneryPass {
  0%   { left: -15%; opacity: 0; }
  5%   { opacity: 1; }
  85%  { opacity: 1; }
  100% { left: 110%; opacity: 0; }
}

/* POI discovery ping */
.poi-ping {
  position: absolute;
  bottom: 36px;
  left: 55%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-gold);
  animation: poiPing 2s ease-out infinite;
  z-index: 4;
}

.poi-ping::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--color-gold);
  animation: pingRing 2s ease-out infinite;
}

@keyframes poiPing {
  0%, 80% { opacity: 0; transform: scale(0); }
  85% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

@keyframes pingRing {
  0%, 80% { opacity: 0; transform: scale(0.5); }
  85% { opacity: 0.8; }
  100% { opacity: 0; transform: scale(3); }
}

/* Loading text */
.route-loading-text {
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-mid);
}

#loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%  { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* GPS Button */
#gps-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--color-primary);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

#gps-btn.active {
  background: var(--color-success);
  border-color: var(--color-success);
  animation: pulse 2s infinite;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* === MAP SECTION (60%) === */
#map-container {
  flex: 6;
  position: relative;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

#poi-label {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#speed-control {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

#direction-btn {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  background: white;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

#direction-btn:active {
  transform: scale(0.95);
}

#direction-btn.reverse {
  background: var(--color-primary);
  color: white;
}

.speed-btn {
  background: white;
  border: 2px solid var(--color-mid);
  color: var(--color-mid);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.speed-btn.active {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: white;
}

/* === CONTROL SECTION (40%) === */
#controls {
  flex: 4;
  min-height: 0;
  background: white;
  border-top: 3px solid var(--color-gold);
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 10px;
  overflow-y: auto;
}

/* Persona & Language Row */
.control-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.control-row select {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--color-bg-light);
  border-radius: 10px;
  font-size: 14px;
  background: var(--color-bg-light);
  color: var(--color-text);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23385D73' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Now Playing */
#now-playing {
  background: var(--color-bg-light);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#now-playing-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
}

#now-playing-text {
  font-size: 13px;
  color: var(--color-mid);
  line-height: 1.4;
  max-height: 60px;
  overflow-y: auto;
}

/* Progress Bar */
#progress-container {
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: var(--color-gold);
  width: 0%;
  transition: width 0.3s;
}

/* Player Buttons */
.player-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  align-items: flex-start;
}

.player-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.btn-label {
  font-size: 10px;
  color: var(--color-mid);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s;
}

.player-btn:active {
  transform: scale(0.92);
}

.btn-secondary {
  background: var(--color-bg-light);
  color: var(--color-mid);
}

.btn-primary {
  background: var(--color-gold);
  color: white;
  width: 56px;
  height: 56px;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(201, 161, 74, 0.4);
}

/* Prepare Button (floating) */
#prepare-btn {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-gold);
  color: white;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(201, 161, 74, 0.4);
  z-index: 100;
  transition: all 0.2s;
}

#prepare-btn:active { transform: scale(0.92); }

#prepare-btn.cached {
  background: var(--color-success);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

/* Pre-Generation Panel */
.pregen-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  padding: 20px;
  z-index: 200;
  transition: transform 0.3s ease;
}

.pregen-panel.hidden {
  display: none !important;
}

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

.pregen-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}

.pregen-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-mid);
  cursor: pointer;
  padding: 4px 8px;
}

.pregen-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-mid);
  margin-bottom: 12px;
}

/* Circular progress ring */
.pregen-ring-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 12px auto;
}

.pregen-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pregen-ring-bg {
  fill: none;
  stroke: var(--color-bg-light);
  stroke-width: 8;
}

.pregen-ring-fill {
  fill: none;
  stroke: var(--color-gold);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.5s ease;
}

.pregen-ring-fill.complete {
  stroke: var(--color-success);
}

.pregen-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.pregen-pct {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.pregen-eta {
  font-size: 12px;
  color: var(--color-mid);
  margin-top: 2px;
}

.pregen-count-label {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 4px;
}

/* Progress bar (thin, under the ring) */
.pregen-progress-bar {
  height: 4px;
  background: var(--color-bg-light);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.pregen-progress-fill {
  height: 100%;
  background: var(--color-gold);
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 2px;
}

.pregen-progress-fill.complete {
  background: var(--color-success);
}

.pregen-status {
  font-size: 13px;
  color: var(--color-mid);
  margin-bottom: 12px;
  min-height: 16px;
  text-align: center;
}

.pregen-actions {
  display: flex;
  gap: 8px;
}

.pregen-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pregen-btn:active { transform: scale(0.97); }

.pregen-btn-primary {
  background: var(--color-gold);
  color: white;
}

.pregen-btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.pregen-btn-secondary {
  background: var(--color-bg-light);
  color: var(--color-mid);
}

.pregen-size {
  font-size: 11px;
  color: #aaa;
  text-align: center;
  margin-top: 8px;
}

/* Voice Button */
#voice-btn {
  position: fixed;
  bottom: 20px;
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(27, 58, 75, 0.4);
  z-index: 100;
  transition: all 0.2s;
}

#voice-btn.listening {
  background: var(--color-error);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(229, 57, 53, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(229, 57, 53, 0.7); }
}

/* Status Bar */
#status-bar {
  font-size: 11px;
  color: var(--color-mid);
  text-align: center;
  padding: 4px;
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-bg-light);
  border-top-color: var(--color-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* Mapbox overrides */
.mapboxgl-ctrl-attrib { font-size: 9px !important; }
.mapboxgl-popup-content { padding: 10px 14px; font-size: 13px; border-radius: 8px; }
