/* assets/css/fare-engine.css */
:root {
  --primary: #FF9B00;
  --primary-dark: #cc7c00;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --card-border: #eaedf1;
  --text-dark: #2c3e50;
  --text-muted: #7f8c8d;
  --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 15px 40px rgba(255, 155, 0, 0.15);
}

body.fare-engine-page {
  background: var(--bg-color);
  color: var(--text-dark);
  font-family: 'Open Sans', sans-serif;
  margin: 0;
  padding-top: 145px; /* Increased to clear the fixed-top header */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Adjust the navbar for the light theme to match main site */
body.fare-engine-page .navbar {
  background: #fff !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
body.fare-engine-page .navbar .nav-link {
  color: #333 !important;
}
body.fare-engine-page .navbar .nav-link:hover,
body.fare-engine-page .navbar .nav-item.active .nav-link {
  color: var(--primary) !important;
}

/* Main Container - Full Bleed Uber Style */
.fare-engine-container {
  display: flex;
  position: relative;
  height: calc(100vh - 145px); /* Fill screen minus header */
  width: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

/* Map takes full background */
.fare-map-wrapper {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  height: 100%;
  width: 100%;
  z-index: 1;
  background: #eaeaea; /* Fallback */
}

#tripMap {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Floating Form Panel */
.fare-sidebar {
  position: absolute;
  top: 20px;
  left: 30px;
  width: 420px;
  max-height: calc(100% - 40px);
  z-index: 10;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-right: 15px; /* for scrollbar */
}
.fare-sidebar.right {
  left: auto;
  right: 30px;
  top: 145px;
  max-height: calc(100% - 175px);
}

/* Hide scrollbar for clean look */
.fare-sidebar::-webkit-scrollbar { width: 4px; }
.fare-sidebar::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.2); border-radius: 4px; }

/* Modern Card Style */
.glass-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 5px;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  background: linear-gradient(90deg, #FF9B00, #ffdd00);
}

.glass-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* Form Styles */
.form-group {
  margin-bottom: 22px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.95rem;
}

.form-control-glass {
  width: 100%;
  padding: 14px 20px 14px 45px;
  background: #f8f9fa;
  border: 1px solid #dfe4ea;
  border-radius: 12px;
  color: var(--text-dark);
  font-size: 1rem;
  transition: all 0.3s ease;
  outline: none;
  font-weight: 500;
  appearance: none; /* remove native dropdown arrow */
  -webkit-appearance: none;
}
/* Re-add a custom dropdown arrow */
.form-group::after {
  content: '\f107';
  font-family: 'FontAwesome';
  font-weight: normal;
  position: absolute;
  right: 18px;
  top: 57px;
  color: var(--text-muted);
  pointer-events: none;
}

.form-control-glass:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 155, 0, 0.15);
}

.form-icon {
  position: absolute;
  left: 16px;
  top: 57px; /* label ~35px + half of input (52px) minus half icon ~10px = ~57px */
  transform: translateY(-50%);
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
}

.btn-calculate {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  letter-spacing: 0.5px;
}

.btn-calculate:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(255, 155, 0, 0.3);
}

/* Results Breakdown */
.breakdown-card {
  display: none;
  animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.breakdown-card.show {
  display: block;
}

.route-summary {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px dashed #f1f2f6;
}

.summary-item {
  text-align: center;
  flex: 1;
}

.summary-item:not(:last-child) {
  border-right: 1px solid #f1f2f6;
}

.summary-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin-bottom: 5px;
}
.summary-item .value {
  font-size: 1.3rem;
  font-weight: 800;
  color: #1a1a1a;
}

.fare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 1rem;
  color: #4a4a4a;
  font-weight: 500;
}

.fare-row span:last-child {
  font-weight: 700;
  color: #2c3e50;
}

.fare-row.total {
  margin-top: 25px;
  padding-top: 25px;
  border-top: 2px solid #f1f2f6;
  font-size: 1.4rem;
  font-weight: 800;
  color: #1a1a1a;
}

.total-value {
  color: #27ae60 !important;
  font-size: 1.8rem;
}

.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  border-radius: 20px;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f1f2f6;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }

/* Map custom tooltip */
.leaflet-popup-content-wrapper {
  background: #fff;
  color: #333;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  font-weight: bold;
}
.leaflet-popup-tip {
  background: #fff;
}
.custom-leaflet-icon {
  background: transparent;
  border: none;
}
.map-marker {
  width: 35px;
  height: 35px;
  background: var(--primary);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: 800;
  font-size: 14px;
  transition: transform 0.2s;
}
.map-marker.home-marker {
  background: #27ae60 !important;
  color: #fff !important;
  border-color: #fff;
  font-size: 10px;
}
.map-marker:hover {
  transform: scale(1.1);
}
.map-marker.end {
  background: #e74c3c;
}

/* Comparison UI */
.compare-card {
  animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.compare-badge {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  padding: 2px 8px;
  font-size: 0.8rem;
  margin-left: 8px;
}
.btn-clear-compare {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-clear-compare:hover {
  opacity: 0.7;
}
.compare-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 5px;
}
.compare-item {
  background: #f8f9fa;
  border: 1px solid #eaedf1;
  border-radius: 12px;
  padding: 12px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}
.compare-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  background: #fff;
}
.compare-item-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.compare-item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a1a;
}
.compare-item-subtitle {
  font-size: 0.75rem;
  color: #7f8c8d;
  font-weight: 600;
}
.compare-item-price {
  font-size: 1.1rem;
  font-weight: 800;
  color: #27ae60;
  text-align: right;
  min-width: 80px;
  margin-right: 15px;
}
.btn-remove-compare {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  padding: 5px;
  font-size: 1rem;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-remove-compare:hover {
  transform: scale(1.1);
}
.compare-list::-webkit-scrollbar { width: 4px; }
.compare-list::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.1); border-radius: 4px; }


/* ---------------------------------
   MOBILE OPTIMIZATION (Uber UX)
------------------------------------ */
@media (max-width: 900px) {
  body.fare-engine-page {
    padding-top: 130px; /* smaller header on mobile but still needs enough room */
  }
  
  .fare-engine-container {
    height: auto;
    min-height: auto;
    display: block;
    overflow: visible;
  }
  
  /* Map stays glued to the top, taking 45vh */
  .fare-map-wrapper {
    position: fixed;
    top: 130px;
    left: 0;
    right: 0;
    height: 45vh;
    z-index: 1;
    border-bottom: 2px solid #eaedf1;
  }

  /* Form overlaps the map slightly from the bottom, scrolls naturally */
  .fare-sidebar {
    position: relative;
    top: auto; left: auto;
    width: 100%;
    margin-top: calc(45vh - 30px); /* 30px overlap over the map */
    z-index: 10;
    padding: 20px 15px 15px;
    background: #f8f9fa;
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    overflow-y: visible;
  }
  
  .fare-sidebar.right {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    width: 100%;
    max-height: none;
    box-sizing: border-box;
    margin-top: 0;
    padding: 10px 15px 30px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    box-shadow: none;
  }

  .glass-card {
    background: #ffffff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.06);
    border: none;
    padding: 25px 20px;
  }
  
  .glass-card::before {
    border-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
  }
}
