/* ============================================
   StrideLens Dashboard — Full-Width Layout
   ============================================ */

/* CSS Variables */
:root {
  /* Primary Brand Colors */
  --accent: #FC4C02;
  --accent-hover: #FF6B2C;
  --accent-glow: rgba(252, 76, 2, 0.25);
  --accent-subtle: rgba(252, 76, 2, 0.1);
  
  /* Dark Theme Colors */
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-elevated: #161616;
  --bg-card: #1A1A1A;
  --bg-card-hover: #222222;
  --bg-input: #252525;
  
  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #B3B3B3;
  --text-muted: #666666;
  --text-accent: var(--accent);
  
  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  /* Semantic Colors */
  --success: #00C853;
  --success-subtle: rgba(0, 200, 83, 0.15);
  --warning: #FFB300;
  --warning-subtle: rgba(255, 179, 0, 0.15);
  --danger: #FF3D3D;
  --danger-subtle: rgba(255, 61, 61, 0.15);
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 4px 20px var(--accent-glow);
  
  /* Layout */
  --header-height: 60px;
  --sidebar-width: 340px;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

/* Desktop: no scroll needed */
@media (min-width: 769px) {
  body {
    overflow: hidden;
  }
}

/* Mobile: allow scrolling */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Dashboard Header
   ============================================ */

.dashboard-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  gap: var(--space-lg);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 17px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Device Connection Bar */
.device-connection-bar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-elevated);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.device-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition-base);
}

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

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

.progress-inline {
  width: 60px;
  height: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-inline .progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.15s linear;
}

/* ============================================
   Dashboard Grid Layout
   ============================================ */

.dashboard-mode {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  gap: 0;
  flex: 1;
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* ============================================
   Sidebars
   ============================================ */

.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: visible;
  overflow-x: visible;
}

.sidebar-right {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
}

/* Custom Scrollbar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

/* ============================================
   Panels
   ============================================ */

.panel {
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-elevated);
  cursor: default;
  user-select: none;
}

.panel-compact .panel-header {
  cursor: pointer;
}

.panel-compact .panel-header:hover {
  background: var(--bg-card);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.panel-title i {
  font-size: 16px;
  color: var(--accent);
}

.panel-toggle {
  font-size: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.panel.collapsed .panel-toggle {
  transform: rotate(-90deg);
}

.panel.collapsed .panel-content {
  display: none;
}

.panel-content {
  padding: var(--space-lg) var(--space-xl);
}

.panel-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.panel-row:last-child {
  margin-bottom: 0;
}

/* ============================================
   Routes List
   ============================================ */

.routes-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
}

@media (min-width: 1600px) {
  .routes-list {
    max-height: 220px;
  }
}

@media (min-width: 1920px) {
  .routes-list {
    max-height: 280px;
  }
}

.route-item {
  display: flex;
  align-items: right;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  width: 91%;
}

.route-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.route-name-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.preview-route-name {
  transition: color var(--transition-fast);
}

.preview-route-name:hover {
  color: var(--text-accent);
  text-decoration: underline;
}

.route-actions {
  display: flex;
  gap: var(--space-xs);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.route-item:hover .route-actions {
  opacity: 1;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-icon-danger:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.empty-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.empty-msg i {
  font-size: 32px;
  opacity: 0.5;
}

/* ============================================
   Upload Zone
   ============================================ */

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
  background: var(--bg-input);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-bottom: var(--space-lg);
}

.upload-zone i {
  font-size: 32px;
  color: var(--accent);
}

.upload-zone span {
  font-size: 13px;
  color: var(--text-muted);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.file-selected {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 11px;
  color: var(--accent);
}

.file-selected i {
  font-size: 14px;
}

/* ============================================
   Map Main Area
   ============================================ */

.map-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}

.map-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow-x: visible;
}

 
  .map-toolbar {
    flex-wrap: auto;
    padding: var(--space-md);
    gap: var(--space-sm);
    overflow: visible !important;

  }

   .map-toolbar .btn {
    order: 3;
  }
  

.geocoder-container {
  width: 240px;
  min-width: 180px;
  flex-shrink: 1;
}

.route-name-input {
  width: 200px;
  min-width: 160px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  flex-shrink: 1;
}

.route-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.error-text {
  font-size: 10px;
  color: var(--danger);
  white-space: nowrap;
}

/* Toast Notification Styles */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-md));
  right: var(--space-md);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 14px;
  min-width: 300px;
  max-width: 400px;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast i {
  font-size: 18px;
  flex-shrink: 0;
}

.toast span {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.toast-close i {
  font-size: 16px;
}

.toast-error {
  border-left: 3px solid var(--danger);
  background: rgba(255, 61, 61, 0.1);
}

.toast-error i {
  color: var(--danger);
}

.toast-success {
  border-left: 3px solid var(--success);
  background: rgba(0, 200, 83, 0.1);
}

.toast-success i {
  color: var(--success);
}

.toast-info {
  border-left: 3px solid var(--text-accent);
  background: rgba(252, 76, 2, 0.1);
}

.toast-info i {
  color: var(--text-accent);
}

/* Input error state */
.input-error {
  border-color: var(--danger) !important;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.toolbar-spacer {
  flex: 1;
  min-width: var(--space-md);
}

#embedded-map-container {
  flex: 1;
  position: relative;
}

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

/* Mapbox Customization */
.mapboxgl-ctrl-geocoder {
  width: 100% !important;
  max-width: none !important;
  background: var(--bg-input) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: none !important;
  font-size: 12px !important;
}

.mapboxgl-ctrl-geocoder input[type="text"] {
  background: transparent !important;
  color: var(--text-primary) !important;
  height: 32px !important;
  padding: 6px 10px 6px 32px !important;
}

.mapboxgl-ctrl-geocoder--icon {
  fill: var(--text-muted) !important;
  top: 8px !important;
  left: 8px !important;
  width: 16px !important;
  height: 16px !important;
}

.mapboxgl-ctrl-geocoder .suggestions {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  font-size: 12px !important;
}

.mapboxgl-ctrl-geocoder .suggestions li {
  color: var(--text-primary) !important;
  padding: 8px 12px !important;
}

.mapboxgl-ctrl-geocoder .suggestions li:hover,
.mapboxgl-ctrl-geocoder .suggestions .active {
  background: var(--bg-elevated) !important;
}


/* Dropdown must overlay the map */
#embedded-map-container {
    overflow: visible !important;
}

/* Geocoder suggestions on top */
.mapboxgl-ctrl-geocoder,
.mapboxgl-ctrl-geocoder .suggestions,
.mapboxgl-ctrl-geocoder .suggestions-wrapper {
    z-index: 99999 !important;
}

/* Force absolute positioning so it detaches from toolbar height */
.mapboxgl-ctrl-geocoder .suggestions {
    position: absolute !important;
    top: 100%;
    left: 0;
    right: 0;
} /* force fix search suggestions on top of map*/

/* Map Marker */
.marker-number {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
  font-weight: 700;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border: 2px solid white;
  box-shadow: var(--shadow-md);
  cursor: grab;
}

.marker-number:active {
  cursor: grabbing;
}

/* ============================================
   Route Preview Panel (Right Sidebar)
   ============================================ */

.panel-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.panel-preview .panel-content {
  flex: 1;
  /* overflow-y: auto;
  overflow-x: hidden; */
  overflow: visible;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Route Preview Canvas */
.preview-canvas-wrap {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-shrink: 0;
}

.preview-canvas-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
  max-height: 200px;
  object-fit: contain;
}

/* Turn-by-Turn in Sidebar */
.turn-list-compact {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.turn-item-compact {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.turn-icon-compact {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  flex-shrink: 0;
}

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

.turn-direction {
  font-weight: 600;
  color: var(--text-primary);
}

.turn-distance {
  color: var(--text-muted);
  font-size: 10px;
}

/* Actions in Sidebar */
.preview-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.action-row {
  display: flex;
  gap: var(--space-sm);
}

.action-row .btn {
  flex: 1;
}

.save-input-row {
  display: flex;
  gap: var(--space-sm);
}

.save-input-row input {
  flex: 1;
  min-width: 0;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  background: var(--bg-input);
  color: var(--text-primary);
}

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

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

.btn i {
  font-size: 16px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-sm i {
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
}

.btn-primary:hover {
  box-shadow: var(--shadow-accent);
}

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

.btn-ghost:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  z-index: 9999 !important;
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger-subtle);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-cta {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: white;
}

.w-full {
  width: 100%;
}

/* ============================================
   Form Elements
   ============================================ */

input[type="text"],
select {
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="text"]::placeholder {
  color: var(--text-muted);
}

.select-compact {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.file-input-compact {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.file-input-compact::file-selector-button {
  display: none;
}

/* ============================================
   Progress Bar
   ============================================ */

.progress {
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-sm);
}

.progress.small {
  height: 3px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.15s linear;
}

/* ============================================
   Activity Log Drawer
   ============================================ */

.log-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  z-index: 200;
  transition: height var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.log-drawer.open {
  height: 200px;
}

.log-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.log-actions {
  display: flex;
  gap: var(--space-sm);
}

.log-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-primary);
  margin: 0;
}

/* ============================================
   Badges
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
}

.badge-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.badge-success {
  background: var(--success-subtle);
  color: var(--success);
}

.badge-accent {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ============================================
   Empty States
   ============================================ */

.empty-state-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-compact i {
  font-size: 32px;
  margin-bottom: var(--space-md);
  opacity: 0.3;
}

.empty-state-compact p {
  font-size: 12px;
  margin-bottom: var(--space-xs);
}

.empty-state-compact span {
  font-size: 11px;
}

/* ============================================
   Utility Classes
   ============================================ */

.muted { color: var(--text-muted); }
.small { font-size: 11px; }
.mt { margin-top: var(--space-md); }
.mb { margin-bottom: var(--space-md); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.hidden { display: none !important; }

/* Error styling */
.error {
  color: var(--danger);
  background: var(--danger-subtle);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 12px;
  margin-bottom: var(--space-md);
}

/* ============================================
   Responsive Adjustments
   ============================================ */

/* Extra large screens - wider sidebars */
@media (min-width: 1600px) {
  :root {
    --sidebar-width: 380px;
  }
}

@media (min-width: 1920px) {
  :root {
    --sidebar-width: 420px;
  }
}

@media (min-width: 2200px) {
  :root {
    --sidebar-width: 480px;
  }
}

/* Tablet and below */
@media (max-width: 1200px) {
  :root {
    --sidebar-width: 300px;
  }
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
    --sidebar-width: 100%;
  }
  
  body {
    font-size: 16px;
  }
  
  .dashboard-grid {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-height));
    overflow-y: auto;
  }
  
  .sidebar-left {
    display: block;
    width: 100%;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
  }
  
  .sidebar-right {
    display: block;
    width: 100%;
    order: 3;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }
  
  .map-main {
    order: 1;
    width: 100%;
    min-height: 50vh;
    flex-shrink: 0;
  }
  
  #embedded-map-container {
    height: 50vh;
    min-height: 300px;
  }
  
  .device-connection-bar {
    display: none;
  }
  
  .dashboard-header {
    padding: 0 var(--space-md);
  }
  
  .header-left {
    flex: 1;
  }
  
  .header-center {
    display: none;
  }
  
  .brand {
    font-size: 16px;
  }
  
  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
 
  
  .geocoder-container {
    width: 100%;
    min-width: 100%;
    order: 1;
  }
  
  .route-name-input {
    flex: 1;
    min-width: 100px;
    order: 2;
  }
  
  .toolbar-spacer {
    display: none;
  }
  
 
  
  .panel-content {
    padding: var(--space-md);
  }
  
  .panel-header {
    padding: var(--space-md);
  }
  
  .upload-zone {
    padding: var(--space-lg);
  }
  
  .btn {
    padding: 12px 16px;
    font-size: 15px;
  }
  
  .btn-sm {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  input[type="text"],
  select {
    padding: 12px 14px;
    font-size: 16px; /* Prevents iOS zoom */
  }
  
  .routes-list {
    max-height: none;
  }
  
  .route-item {
    padding: var(--space-md);
  }
  
  .route-name-text {
    font-size: 15px;
  }
  
  /* Activity log on mobile */
  .log-drawer.open {
    height: 40vh;
  }
  
  /* Mobile-specific controls */
  .mobile-menu-btn {
    display: flex;
  }
}

/* Small phones */
@media (max-width: 480px) {
  :root {
    --header-height: 52px;
  }
  
  body {
    font-size: 15px;
  }
  
  .dashboard-header {
    padding: 0 var(--space-sm);
  }
  
  .brand {
    font-size: 15px;
  }
  
  .brand-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
 
  #embedded-map-container {
    height: 40vh;
    min-height: 250px;
  }
  
  .panel-header {
    padding: var(--space-sm) var(--space-md);
  }
  
  .panel-content {
    padding: var(--space-sm) var(--space-md);
  }
  
  .panel-title {
    font-size: 12px;
  }
  
  .btn {
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .btn-sm {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .upload-zone {
    padding: var(--space-md);
  }
  
  .upload-zone i {
    font-size: 28px;
  }
  
  .upload-zone span {
    font-size: 12px;
  }
  
  .route-item {
    padding: var(--space-sm) var(--space-md);
  }
  
  .route-name-text {
    font-size: 14px;
  }
  
  .empty-msg {
    padding: var(--space-lg);
    font-size: 13px;
  }
  
  .empty-msg i {
    font-size: 28px;
  }
}

/* ============================================
   Legacy Compatibility (for _route_section.html)
   ============================================ */

/* Canvas wrap */
.canvas-wrap {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* Turn list (legacy) */
.turn-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.turn-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.turn-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.turn-text {
  flex: 1;
  min-width: 0;
}

.turn-main {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.turn-dist {
  font-size: 10px;
  color: var(--text-muted);
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.input-group {
  display: flex;
  gap: var(--space-sm);
}

/* Card styling for route section */
.card {
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-md);
}

.card-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.card-title-icon {
  width: 24px;
  height: 24px;
  background: var(--accent-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 12px;
}

/* Section header */
.section-header {
  display: none;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.empty-state-icon i {
  font-size: 24px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 12px;
  margin-bottom: var(--space-xs);
}

/* Card elevated for route actions */
.card-elevated,
.card-accent {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
}

.card-accent {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(252, 76, 2, 0.05), transparent);
}

/* Download link */
.download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
}

.download:hover {
  background: var(--accent-hover);
}

/* ============================================
   Activity Analysis Styles
   ============================================ */

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: var(--space-lg) 0 var(--space-sm) 0;
}

.section-label:first-child {
  margin-top: 0;
}

.activity-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.stat-card {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.stat-card .stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.stat-card .stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.activity-map-container {
  width: 100%;
  height: 200px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-input);
  margin-bottom: var(--space-md);
}

.activity-map-container #activity-map-inner {
  width: 100%;
  height: 100%;
}

.chart-container {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
  min-height: 120px;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
}

.pace-segments-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pace-segments-table thead {
  background: var(--accent);
}

.pace-segments-table th {
  padding: var(--space-sm);
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
}

.pace-segments-table td {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.pace-segments-table tbody tr:hover {
  background: var(--bg-elevated);
}

@media (min-width: 1600px) {
  .activity-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .activity-map-container {
    height: 280px;
  }
}

@media (max-width: 768px) {
  .activity-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-card {
    padding: var(--space-sm);
  }
  
  .stat-card .stat-value {
    font-size: 14px;
  }
  
  .activity-map-container {
    height: 180px;
  }
}

/* Logbox fallback */
.logbox {
  width: 100%;
  height: 150px;
  overflow-y: auto;
  padding: var(--space-md);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* ============================================
   Tooltips
   ============================================ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease 0.5s, visibility 0.15s ease 0.5s, transform 0.15s ease 0.5s;
  z-index: 999999 !important;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 10px 14px;
  background: #111111 !important;
  color: #FFFFFF !important;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 8px;
  border: 2px solid #444444;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255,255,255,0.1);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

[data-tooltip]::after {
  content: '';
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 8px solid transparent;
  border-top-color: #111111;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateX(-50%) translateY(0);
}

/* Tooltip positions - Bottom (for header items) */
[data-tooltip-pos="bottom"]::before {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 4px);
  border-top-color: transparent;
  border-bottom-color: #111111;
  transform: translateX(-50%) translateY(-4px);
}

[data-tooltip-pos="bottom"]:hover::before,
[data-tooltip-pos="bottom"]:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* Tooltip positions - Left */
[data-tooltip-pos="left"]::before {
  bottom: auto;
  left: auto;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) translateX(4px);
}

[data-tooltip-pos="left"]::after {
  bottom: auto;
  left: auto;
  right: calc(100% + 4px);
  top: 50%;
  border-top-color: transparent;
  border-left-color: #111111;
  transform: translateY(-50%) translateX(4px);
}

[data-tooltip-pos="left"]:hover::before,
[data-tooltip-pos="left"]:hover::after {
  transform: translateY(-50%) translateX(0);
}

/* Header tooltips should go below */
.dashboard-header [data-tooltip]::before {
  bottom: auto;
  top: calc(100% + 10px);
  transform: translateX(-50%) translateY(-4px);
}

.dashboard-header [data-tooltip]::after {
  bottom: auto;
  top: calc(100% + 4px);
  border-top-color: transparent;
  border-bottom-color: #111111;
  transform: translateX(-50%) translateY(-4px);
}

.dashboard-header [data-tooltip]:hover::before,
.dashboard-header [data-tooltip]:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Number Counter Animation
   ============================================ */

.animate-count {
  display: inline-block;
}

.animate-count.counting {
  animation: countPulse 0.3s ease-out;
}

@keyframes countPulse {
  0% {
    transform: scale(1);
    color: var(--text-primary);
  }
  50% {
    transform: scale(1.15);
    color: var(--accent);
  }
  100% {
    transform: scale(1);
    color: var(--text-primary);
  }
}

/* Stat value animation */
.stat-value {
  transition: all 0.3s ease;
}

.stat-value.updated {
  animation: statUpdate 0.5s ease;
}

@keyframes statUpdate {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Badge count animation */
.badge.animate {
  animation: badgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   Better Empty States
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  min-height: 200px;
}

.empty-state-illustration {
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-lg);
  opacity: 0.6;
  animation: floatIllustration 3s ease-in-out infinite;
}

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

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-subtle), transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  animation: pulseGlow 2s ease-in-out infinite;
}

.empty-state-icon i {
  font-size: 28px;
  color: var(--accent);
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 var(--accent-glow);
  }
  50% {
    box-shadow: 0 0 20px 5px var(--accent-glow);
  }
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 240px;
  line-height: 1.5;
}

.empty-state-compact {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-compact i {
  font-size: 32px;
  margin-bottom: var(--space-sm);
  opacity: 0.5;
  animation: subtlePulse 2s ease-in-out infinite;
}

@keyframes subtlePulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.8;
  }
}

.empty-state-compact p {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.empty-state-compact span {
  font-size: 11px;
  opacity: 0.7;
}

/* Route list empty state */
.routes-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-xl);
  text-align: center;
}

.routes-list-empty .empty-illustration {
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-md);
}

.routes-list-empty .empty-illustration::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-subtle), transparent);
  border-radius: 50%;
  animation: rotate 8s linear infinite;
}

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

.routes-list-empty .empty-illustration i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: var(--accent);
}

/* ============================================
   Undo/Redo Controls
   ============================================ */

.undo-redo-controls {
  display: flex;
  gap: var(--space-xs);
}

.undo-redo-controls .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.undo-redo-controls .btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.undo-redo-controls .btn i {
  font-size: 16px;
}

/* Keyboard shortcut hints */
.shortcut-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: var(--space-sm);
  opacity: 0.5;
}

.shortcut-hint kbd {
  display: inline-block;
  padding: 2px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  color: var(--text-muted);
}
