/* ========================================
   UI POLISH - ADDITIONAL IMPROVEMENTS
   ========================================
   Extra touches to make everything feel
   more polished and professional.
*/

/* ========================================
   MICRO-INTERACTIONS & TRANSITIONS
   ======================================== */

/* Smooth transitions everywhere */
*, *::before, *::after {
  transition-property: color, background-color, border-color, box-shadow, transform, opacity;
  transition-duration: 0.15s;
  transition-timing-function: ease-out;
}

/* Disable transitions for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ========================================
   ENHANCED FORM CONTROLS
   ======================================== */

/* Input focus glow */
input:focus,
select:focus,
textarea:focus {
  box-shadow: 0 0 0 3px rgba(0, 160, 225, 0.25);
}

/* Better select dropdown styling */
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Input placeholder styling */
::placeholder {
  color: #888;
  opacity: 1;
}

/* Number input spinner removal (cleaner look) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ========================================
   BETTER CHECKBOX STYLING
   ======================================== */

/* Custom checkbox design */
.consent-checkbox input[type="checkbox"],
.preference-checkbox input[type="checkbox"],
.area-toggle input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color, #D4D2CC);
  border-radius: var(--radius-sm, 4px);
  background: var(--surface, #FFFFFF);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.consent-checkbox input[type="checkbox"]:checked,
.preference-checkbox input[type="checkbox"]:checked,
.area-toggle input[type="checkbox"]:checked {
  background: var(--primary, #E1251B);
  border-color: var(--primary, #E1251B);
}

.consent-checkbox input[type="checkbox"]:checked::after,
.preference-checkbox input[type="checkbox"]:checked::after,
.area-toggle input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.consent-checkbox input[type="checkbox"]:focus-visible,
.preference-checkbox input[type="checkbox"]:focus-visible,
.area-toggle input[type="checkbox"]:focus-visible {
  outline: 2px solid #00A0E1;
  outline-offset: 2px;
}

/* ========================================
   IMPROVED BUTTON STATES
   ======================================== */

/* Disabled state - more obvious */
.btn:disabled,
.btn[disabled],
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(50%);
  pointer-events: none;
}

/* Button with icon alignment */
.btn svg,
.btn img {
  vertical-align: middle;
  margin-right: 0.5em;
}

/* Small button refinements */
.btn-small {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

/* Ghost/outline button variant */
.btn-ghost {
  background: transparent;
  border: 2px solid currentColor;
  color: var(--primary, #E1251B);
}

.btn-ghost:hover {
  background: var(--primary, #E1251B);
  color: white;
}

/* ========================================
   CARDS & CONTAINERS
   ======================================== */

/* Card hover lift effect */
.card,
.glass-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover,
.glass-card:hover {
  transform: none;
}

/* Better card shadows */
.card,
.results-box {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card:hover,
.results-box:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ========================================
   BETTER MESSAGES & ALERTS
   ======================================== */

/* Success message */
.message.success,
.message-success {
  background: #2E7D32;
  color: white;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md, 8px);
  border-left: 3px solid #4CAF50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message.success::before,
.message-success::before {
  content: '✓';
  font-size: 1.25rem;
  font-weight: bold;
}

/* Error message */
.message.error,
.message-error {
  background: #C62828;
  color: white;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md, 8px);
  border-left: 3px solid #EF5350;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message.error::before,
.message-error::before {
  content: '⚠';
  font-size: 1.25rem;
}

/* Warning message */
.message.warning,
.message-warning {
  background: #F57C00;
  color: white;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md, 8px);
  border-left: 3px solid #FFB74D;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message.warning::before,
.message-warning::before {
  content: '⚡';
  font-size: 1.25rem;
}

/* Info message */
.message.info,
.message-info,
.info-message {
  background: var(--secondary, #003688);
  color: white;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md, 8px);
  border-left: 3px solid var(--accent, #00A0E1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.message.info::before,
.message-info::before,
.info-message::before {
  content: 'ℹ';
  font-size: 1.25rem;
  font-weight: bold;
}

/* Message animation */
.message {
  animation: message-slide-in 0.3s ease-out;
}

@keyframes message-slide-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   TOOLTIPS
   ======================================== */

[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background: #222;
  color: white;
  font-size: 0.8rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #222;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1001;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus::after,
[data-tooltip]:focus::before {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   IMPROVED EMPTY STATES
   ======================================== */

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: #888;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  color: #ccc;
  margin-bottom: 0.5rem;
}

.empty-state-description {
  max-width: 300px;
  margin: 0 auto 1.5rem;
  line-height: 1.5;
}

.empty-state-action {
  margin-top: 1rem;
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Pulsing placeholder */
.loading-pulse {
  animation: loading-pulse 1.5s ease-in-out infinite;
}

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

/* Inline loading spinner */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-inline::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Full-screen loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-overlay-content {
  text-align: center;
  color: white;
}

.loading-overlay-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary, #E1251B);
  border-bottom-color: var(--primary, #E1251B);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

/* ========================================
   BADGE/TAG STYLING
   ======================================== */

.badge,
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary { background: var(--primary, #E1251B); color: white; }
.badge-success { background: #2E7D32; color: white; }
.badge-warning { background: #F57C00; color: white; }
span.badge-info, .badge.badge-info { background: #1565C0; color: white; }
.badge-card .badge-info { background: transparent; color: inherit; }
.badge-muted { background: #555; color: #ccc; }

/* ========================================
   IMPROVED SCROLLBARS (non-pub mode)
   ======================================== */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary, #F4F3EE);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color, #D4D2CC);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted, #767676);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color, #D4D2CC) var(--bg-secondary, #F4F3EE);
}

/* ========================================
   MOBILE ENHANCEMENTS
   ======================================== */

@media (max-width: 768px) {
  /* Larger touch targets */
  .btn,
  button,
  select,
  input[type="checkbox"],
  .nav-tab {
    min-height: 44px;
  }
  
  /* Better spacing on mobile */
  .control-group {
    margin-bottom: 1.25rem;
  }
  
  /* Full-width buttons on mobile */
  .export-buttons .btn,
  .route-export-section .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Sticky header on mobile */
  header {
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  /* Bottom padding for mobile (avoid nav overlap) */
  body {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

@media (max-width: 480px) {
  /* Even more compact on small screens */
  .card,
  .glass-card {
    padding: 1rem;
    border-radius: 12px;
  }
  
  h2 {
    font-size: 1.4rem;
  }
  
  .btn-large {
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
  }
}

/* ========================================
   DARK MODE REFINEMENTS & CONTRAST FIXES
   ======================================== */

/* Force readable input text everywhere */
input,
select,
textarea {
  color: var(--text-primary, #1D1D1B) !important;
  background-color: var(--surface, #FFFFFF) !important;
}

input::placeholder {
  color: var(--text-muted, #767676) !important;
  opacity: 1;
}

/* Auth/Login form specific fixes */
.auth-form input,
.auth-form select {
  background: var(--surface, #FFFFFF) !important;
  color: var(--text-primary, #1D1D1B) !important;
  border: 2px solid var(--border-color, #D4D2CC);
}

.auth-form input:focus,
.auth-form select:focus {
  border-color: var(--accent, #00A0E1);
  background: var(--surface, #FFFFFF) !important;
}

.auth-form label {
  color: #fff;
}

.auth-form .form-help,
.auth-form small {
  color: #bbb !important;
}

/* Auth container contrast */
.auth-container,
.ticket-machine {
  color: #fff;
}

/* Guest mode option */
.guest-option {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  text-align: center;
}

.guest-option p {
  color: #ccc;
  margin-bottom: 0.5rem;
}

.guest-option small {
  color: #888;
  font-size: 0.85rem;
}

.guest-option .btn-ghost {
  margin-left: 0.5rem;
}

/* Guest badge in header */
.guest-badge {
  background: var(--bg-tertiary, #E8E6E1);
  color: var(--text-secondary, #4A4A4A);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.85rem;
  border: 1px solid var(--border-color, #D4D2CC);
}

.auth-container h2 {
  color: #fff;
}

.auth-toggle p {
  color: #ccc;
}

.auth-toggle button {
  color: #5cb3ff;
}

/* Consent fieldset */
.consent-fieldset {
  color: #fff;
}

.consent-fieldset legend {
  color: #fff;
}

.consent-checkbox {
  color: #ddd !important;
}

.consent-checkbox a {
  color: #5cb3ff;
}

/* Control groups - ensure labels visible */
.control-group label {
  color: #fff;
}

.control-group small,
.control-group .form-help {
  color: #aaa !important;
}

/* Fixed station section */
.fixed-station-section label {
  color: #fff !important;
}

.fixed-station-section small {
  color: #aaa !important;
}

.fixed-station-section input {
  background: var(--surface, #FFFFFF) !important;
  color: var(--text-primary, #1D1D1B) !important;
}

/* Settings section contrast */
.settings-section h3,
.settings-section h4 {
  color: #fff;
}

.settings-section p,
.settings-section span {
  color: #ddd;
}

.settings-section label {
  color: #ccc;
}

.account-info .info-item label {
  color: #aaa;
}

.account-info .info-item span {
  color: #fff;
}

/* Data rights items */
.right-item h4 {
  color: #fff;
}

.right-item p {
  color: #ccc;
}

/* Route form cards */
.route-form-card label,
.route-card-content label {
  color: #fff !important;
}

.route-form-card small,
.route-card-content small {
  color: #aaa !important;
}

.route-form-card p {
  color: #ddd;
}

/* Radio options text */
.radio-option .radio-label strong {
  color: #fff !important;
}

.radio-option .radio-label small {
  color: #aaa !important;
}

/* Distance reference - MUST be visible */
.distance-reference {
  color: #fff !important;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-top: 0.5rem;
}

.distance-reference strong {
  color: #ffcc00 !important;
}

#distanceReference {
  color: #fff !important;
}

/* ========================================
   ACHIEVEMENTS PAGE CONTRAST FIXES
   ======================================== */

/* Achievement page contrast fixes */
#achievements .card,
#achievements .glass-card,
.achievements-container {
  background: var(--surface, #FFFFFF);
}

#achievements h2,
#achievements h3 {
  color: var(--text-primary);
}

#achievements p {
  color: var(--text-secondary);
}

/* Category tabs */
.achievement-category-tabs .category-tab {
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.achievement-category-tabs .category-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.achievement-category-tabs .category-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Category sections */
.achievement-category-section h3 {
  color: var(--text-primary);
}

.category-description {
  color: var(--text-secondary);
}

/* ========================================
   HISTORICAL PAGE CONTRAST FIXES
   ======================================== */

/* Timeline container - light bg needs dark text */
.historical-timeline-container {
  color: #333;
}

.historical-timeline-container h3,
.historical-timeline-container h4,
.timeline-title {
  color: #222 !important;
}

.historical-timeline-container p,
.historical-timeline-container span,
.timeline-subtitle {
  color: #444 !important;
}

/* Timeline items */
.timeline-item,
.era-card {
  color: #333;
}

.era-card h4,
.timeline-item h4 {
  color: #222 !important;
}

.era-card p,
.era-card span,
.timeline-item p {
  color: #555 !important;
}

/* Historical period info */
.historical-period-info {
  color: #333;
}

.historical-period-info h3,
.historical-period-info h4 {
  color: #222 !important;
}

.historical-period-info p,
.historical-period-info span,
.historical-period-info li {
  color: #444 !important;
}

/* Historical controls card */
.historical-controls-card {
  background: var(--surface, #FFFFFF) !important;
}

.historical-controls-card h3,
.historical-controls-card label {
  color: var(--text-primary) !important;
}

.historical-controls-card p,
.historical-controls-card small {
  color: var(--text-secondary) !important;
}

/* Historical results */
.historical-results-container,
.enhanced-historical-route {
  background: var(--surface, #FFFFFF) !important;
}

.historical-route-header h3 {
  color: #fff !important;
}

.route-historical-context {
  color: #ccc !important;
}

/* ========================================
   BOROUGH PROGRESS CONTRAST FIXES
   ======================================== */

/* Borough items */
.borough-progress-item {
  background: var(--bg-secondary, #F4F3EE) !important;
  border: 1px solid var(--border-color, #D4D2CC);
}

.borough-progress-item:hover {
  background: var(--bg-tertiary, #E8E6E1) !important;
}

.borough-name {
  color: var(--text-primary) !important;
}

.borough-stats {
  color: var(--text-secondary) !important;
}

.borough-percentage {
  color: var(--text-primary) !important;
}

.borough-header {
  color: #fff;
}

.borough-details span,
.borough-details small {
  color: #aaa !important;
}

/* Borough progress summary */
.borough-progress-summary {
  color: #ccc;
}

.borough-progress-summary h3 {
  color: #fff !important;
}

/* Borough indicator colors */
.borough-indicator {
  opacity: 1 !important;
}

/* ========================================
   PROGRESS PAGE CONTRAST FIXES
   ======================================== */

.progress-card {
  background: var(--surface, #FFFFFF) !important;
}

.progress-card h3 {
  color: var(--text-primary) !important;
}

.progress-card p,
.progress-card span {
  color: var(--text-secondary) !important;
}

/* Line progress items */
.line-progress-item {
  background: var(--bg-secondary, #F4F3EE) !important;
}

.line-progress-item .line-name {
  color: var(--text-primary) !important;
}

.line-progress-item .line-stats {
  color: var(--text-secondary) !important;
}

/* Overview stats */
.overview-progress .progress-item {
  color: #ccc;
}

.overview-progress .progress-item strong {
  color: #fff;
}

/* Info messages */
.info-message {
  color: #fff !important;
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
  background: var(--surface, #FFFFFF);
  border: 1px solid var(--border-color, #D4D2CC);
  color: var(--text-primary, #1D1D1B);
}

.autocomplete-dropdown .autocomplete-item {
  color: var(--text-primary, #1D1D1B);
  padding: 0.75rem 1rem;
}

.autocomplete-dropdown .autocomplete-item:hover {
  background: var(--bg-secondary, #F4F3EE);
}

@media (prefers-color-scheme: dark) {
  /* Ensure good contrast */
  .form-help,
  small {
    color: #aaa;
  }
  
  /* Links in dark mode */
  a {
    color: #5cb3ff;
  }
  
  a:hover {
    color: #7fc4ff;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  /* Hide non-essential elements */
  header,
  .mode-switcher,
  .nav-tabs,
  .btn,
  .export-buttons,
  .auth-info {
    display: none !important;
  }
  
  /* Ensure content is visible */
  .hidden {
    display: block !important;
  }
  
  /* Reset colors for printing */
  body {
    background: white !important;
    color: black !important;
  }
  
  .card,
  .glass-card {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
}

/* ========================================
   COLLAPSIBLE CARDS
   ======================================== */

.collapsible-card {
  overflow: hidden;
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.2s ease;
}

.collapsible-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.collapsible-header .collapse-icon {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform 0.3s ease;
  color: #888;
}

.collapsible-card.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.collapsible-content {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.collapsible-card.collapsed .collapsible-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* Ensure route-card-content has padding we can animate */
.collapsible-card .route-card-content {
  padding: 1rem 0;
}

.collapsible-card.collapsed .route-card-content {
  padding: 0;
}

/* ========================================
   UTILITIES
   ======================================== */

/* Text utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: #888; }
.text-small { font-size: 0.85rem; }

/* Spacing utilities */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Display utilities */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Flex utilities */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ========================================
   RANDOMISE BUTTON
   ======================================== */

.randomise-btn {
  background: var(--secondary, #003688);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md, 8px);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
  margin-bottom: 1rem;
}

.randomise-btn:hover {
  background: #002a6d;
  box-shadow: 0 4px 12px rgba(0, 54, 136, 0.3);
  transform: none;
}

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

/* ========================================
   MOBILE STICKY GENERATE
   ======================================== */

@media (max-width: 768px) {
  .generate-section {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: linear-gradient(to top, var(--bg-secondary, #F4F3EE) 80%, transparent);
    padding: 1rem 0 1.5rem;
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .generate-section .randomise-btn {
    width: 100%;
    margin-bottom: 0.75rem;
  }
}

/* ========================================
   ESTIMATED TIME DISPLAY
   ======================================== */

.estimated-times {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary, #242444);
  border-radius: 8px;
}

.time-estimate {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary, #a0a0b0);
}

.time-estimate .icon {
  font-size: 1.1rem;
}

.time-estimate .value {
  font-weight: 600;
  color: var(--text-primary, #ffffff);
}

/* ========================================
   LINE FILTER PRESETS
   ======================================== */

.line-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #333);
}

.preset-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  background: var(--bg-secondary, #242444);
  color: var(--text-primary, #fff);
  border: 1px solid var(--border-color, #444);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--accent-color, #00a0e1);
  border-color: var(--accent-color, #00a0e1);
  transform: translateY(-1px);
}

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

.preset-btn[data-preset="all"],
.preset-btn[data-preset="none"] {
  background: transparent;
  border-style: dashed;
}

/* ========================================
   FIRST RUN CELEBRATION
   ======================================== */

.first-run-celebration {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  animation: fadeInOut 4s ease-in-out forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.celebration-content {
  text-align: center;
  color: white;
}

.celebration-message {
  animation: popIn 0.5s ease-out 0.3s both;
}

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

.celebration-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 1rem;
  animation: bounce 0.6s ease infinite;
}

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

.celebration-message h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #FFD300;
}

.celebration-message p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ========================================
   HAIR OF THE DOG TOGGLE
   ======================================== */

.hair-of-dog-toggle {
  background: linear-gradient(135deg, rgba(139, 69, 19, 0.2) 0%, rgba(210, 105, 30, 0.2) 100%);
  border: 1px dashed #D2691E;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.fun-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.fun-toggle input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 50px;
  height: 26px;
  background: #444;
  border-radius: 13px;
  transition: background 0.3s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.fun-toggle input:checked + .toggle-slider {
  background: #D2691E;
}

.fun-toggle input:checked + .toggle-slider::after {
  transform: translateX(24px);
}

.hair-of-dog-toggle small {
  display: block;
  margin-top: 0.5rem;
  margin-left: calc(50px + 0.75rem);
  color: var(--text-secondary, #a0a0b0);
  font-size: 0.85rem;
}

/* ========================================
   RUN HISTORY STATS
   ======================================== */

.run-history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary, #242444);
  border-radius: 12px;
  border-left: 4px solid var(--accent-color, #00a0e1);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-primary, #1a1a2e);
  border-radius: 20px;
  font-size: 0.9rem;
}

.stat-pill .stat-icon {
  font-size: 1.1rem;
}

.stat-pill strong {
  color: var(--accent-color, #00a0e1);
}

@media (max-width: 600px) {
  .run-history-stats {
    flex-direction: column;
  }
  
  .stat-pill {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ========================================
   AREA FILTER PRESETS
   ======================================== */

.area-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color, #333);
}

/* ========================================
   POSTCODE BOX FIX
   ======================================== */

/* Ensure postcodes fit in boxes */
.enhanced-postcode-districts {
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}

.enhanced-postcode-district-toggle {
  padding: 0.5rem 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* On smaller screens, allow more space */
@media (max-width: 480px) {
  .enhanced-postcode-districts {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
  
  .enhanced-postcode-district-toggle {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
  }
}
