/* ==========================================================================
   ROUTEGO DEDICATED LIVE GPS TRACKING STYLESHEET (v2.0 Sleek 2-Column Layout)
   Leaflet.js + OpenStreetMap Interface & Live Telemetry Dashboard
   ========================================================================== */

.rg-tracking-portal-wrap {
  min-height: 100vh;
  background-color: #F1F5F9 !important;
  display: flex;
  flex-direction: column;
}

.rg-tracking-main {
  flex: 1;
  padding: 22px 20px 56px;
}

.rg-tracking-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Legacy & Unified Navbar Support ── */
.rg-navbar-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rg-navbar-left,
.rg-navbar-center,
.rg-navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rg-logo {
  height: 38px;
  width: auto;
  display: block;
}

/* ── Top Live GPS Pill ── */
.rg-tracking-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFF1F2;
  border: 1px solid #FECDD3;
  color: #D84E55;
  padding: 5px 13px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 800;
}

.rg-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D84E55;
  box-shadow: 0 0 0 0 rgba(216, 78, 85, 0.7);
  animation: rg-pulse 1.8s infinite;
}

@keyframes rg-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(216, 78, 85, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(216, 78, 85, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(216, 78, 85, 0); }
}

.rg-back-to-portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 9999px;
  color: #1E293B;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.rg-back-to-portal-btn:hover {
  background: #FFF1F2;
  border-color: #FECDD3;
  color: #D84E55;
}

/* ── Generic Tracking Card ── */
.rg-track-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 16px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

/* ── Trip Header Card ── */
.rg-track-header-card {
  padding: 20px 24px;
  background: linear-gradient(135deg, #FFFFFF 0%, #FFFDFD 100%);
}

.rg-track-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.rg-track-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.rg-track-code-badge {
  background: #0F172A;
  color: #FFFFFF;
  font-family: var(--font-en), system-ui;
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.4px;
}

.rg-vip-pill {
  background: #FEF3C7;
  color: #B45309;
  border: 1px solid #FDE68A;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
}

.rg-status-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rg-status-pill.on-route,
.rg-status-pill.en_route {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.rg-status-pill.delayed {
  background: #FFFBEB;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.rg-track-main-title {
  font-size: 22px;
  font-weight: 900;
  color: #0F172A;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rg-title-arrow {
  color: #D84E55;
  font-size: 20px;
}

.rg-track-sub-details {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748B;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}

.rg-sub-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rg-sub-divider {
  color: #CBD5E1;
}

/* ── Header Controls & Trip Switcher ── */
.rg-track-controls-cluster {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.rg-track-switcher-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rg-switcher-label {
  font-size: 11.5px;
  color: #475569;
  font-weight: 700;
}

.rg-trip-select {
  background: #F8FAFC;
  border: 1.5px solid #CBD5E1;
  padding: 9px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
  cursor: pointer;
  outline: none;
  min-width: 240px;
  transition: all 0.2s ease;
}

.rg-trip-select:hover,
.rg-trip-select:focus {
  border-color: #D84E55;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.12);
}

/* ── Telemetry Grid (4 KPI Cards) ── */
.rg-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.rg-telemetry-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rg-telemetry-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px rgba(15, 23, 42, 0.07);
}

.rg-telemetry-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rg-telemetry-icon.speed {
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid #BFDBFE;
}

.rg-telemetry-icon.progress-icon {
  background: #ECFDF5;
  color: #059669;
  border: 1px solid #A7F3D0;
}

.rg-telemetry-icon.next-stop {
  background: #FEF3C7;
  color: #D97706;
  border: 1px solid #FDE68A;
}

.rg-telemetry-icon.eta {
  background: #FFF1F2;
  color: #D84E55;
  border: 1px solid #FECDD3;
}

.rg-telemetry-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.rg-tel-label {
  font-size: 11.5px;
  color: #64748B;
  font-weight: 700;
}

.rg-tel-value {
  font-size: 22px;
  font-weight: 900;
  color: #0F172A;
  line-height: 1.25;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.rg-tel-value.text-md {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.rg-tel-unit {
  font-size: 12px;
  font-weight: 700;
  color: #64748B;
}

.rg-track-progress-bar {
  width: 100%;
  height: 6px;
  background: #E2E8F0;
  border-radius: 9999px;
  overflow: hidden;
  margin: 4px 0 2px;
}

.rg-track-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #059669);
  border-radius: 9999px;
  transition: width 0.6s ease;
}

.rg-tel-sub {
  font-size: 11px;
  color: #64748B;
  font-weight: 600;
}

.rg-tel-sub.success {
  color: #059669;
}

.rg-tel-sub.warning {
  color: #B45309;
}

/* ── 2-Column Workspace Grid (Map + Sidebar Checkpoints) ── */
.rg-tracking-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
}

/* ── Map Container & Controls ── */
.rg-map-card {
  position: relative;
  display: flex;
  flex-direction: column;
}

.rg-map-controls-strip {
  padding: 12px 18px;
  background: #0F172A;
  color: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.rg-map-live-status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 700;
}

.rg-ping-radar {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: rg-radar 1.5s infinite;
}

@keyframes rg-radar {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.rg-sync-countdown {
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-family: var(--font-en), system-ui;
  color: #CBD5E1;
}

.rg-map-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rg-map-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  padding: 7px 13px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rg-map-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.rg-map-btn.simulation {
  background: #D84E55;
  border-color: #D84E55;
  box-shadow: 0 2px 10px rgba(216, 78, 85, 0.35);
}

.rg-map-btn.simulation:hover {
  background: #C53E45;
}

.rg-leaflet-container {
  z-index: 1;
  flex: 1;
  min-height: 460px;
}

/* ── Map Legend ── */
.rg-map-legend {
  padding: 12px 18px;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
}

.rg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.rg-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.rg-leg-dot.origin { background: #10B981; }
.rg-leg-dot.bus { background: #D84E55; box-shadow: 0 0 0 3px rgba(216, 78, 85, 0.25); }
.rg-leg-dot.destination { background: #0F172A; }

.rg-leg-line {
  width: 20px;
  height: 4px;
  border-radius: 2px;
}

.rg-leg-line.completed { background: #10B981; }
.rg-leg-line.remaining { background: #D84E55; }

/* ── Custom Leaflet Bus Marker ── */
.rg-leaflet-bus-icon {
  background: transparent;
  border: none;
}

.rg-bus-marker-pulse-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rg-bus-radar-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(216, 78, 85, 0.28);
  animation: rg-bus-radar 2s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes rg-bus-radar {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.65); opacity: 0; }
}

.rg-bus-marker-core {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #D84E55;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(216, 78, 85, 0.45);
  border: 2.5px solid #FFFFFF;
}

.rg-terminal-pin {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.rg-terminal-pin.origin { background: #10B981; }
.rg-terminal-pin.destination { background: #0F172A; }
.rg-terminal-pin.checkpoint { background: #F59E0B; }

/* ── Vertical Route Checkpoints Sidebar Card ── */
.rg-timeline-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.rg-card-title {
  font-size: 15px;
  font-weight: 800;
  color: #0F172A;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rg-waypoints-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding: 4px 0;
}

.rg-wp-step {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 13px;
  position: relative;
  padding-bottom: 20px;
}

.rg-wp-step:last-child {
  padding-bottom: 4px;
}

.rg-wp-line {
  position: absolute;
  top: 26px;
  bottom: 0;
  right: 12.5px;
  width: 2.5px;
  background: #E2E8F0;
  z-index: 1;
}

.rg-ltr .rg-wp-line {
  right: auto;
  left: 12.5px;
}

.rg-wp-step:last-child .rg-wp-line {
  display: none !important;
}

.rg-wp-step.passed .rg-wp-line {
  background: #10B981;
}

.rg-wp-node {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #F8FAFC;
  border: 2.5px solid #CBD5E1;
  color: #94A3B8;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.rg-wp-step.passed .rg-wp-node {
  border-color: #10B981;
  background: #10B981;
  color: #FFFFFF;
}

.rg-wp-step.current .rg-wp-node {
  border-color: #D84E55;
  background: #D84E55;
  color: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(216, 78, 85, 0.18);
}

.rg-wp-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.rg-wp-label {
  font-size: 13.5px;
  font-weight: 800;
  color: #1E293B;
  line-height: 1.3;
}

.rg-wp-step.current .rg-wp-label {
  color: #D84E55;
}

.rg-wp-type {
  font-size: 11.5px;
  color: #64748B;
  font-weight: 600;
}

/* ── Captain & Support Box inside Sidebar ── */
.rg-track-support-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rg-support-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rg-support-role {
  font-size: 11px;
  color: #64748B;
  font-weight: 700;
}

.rg-support-title {
  font-size: 13px;
  font-weight: 800;
  color: #0F172A;
}

.rg-support-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #10B981;
  color: #FFFFFF;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.rg-support-wa-btn:hover {
  background: #059669;
}

/* ── Responsive Rules ── */
@media (max-width: 1080px) {
  .rg-tracking-workspace-grid {
    grid-template-columns: 1fr;
  }
  .rg-telemetry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .rg-tracking-main {
    padding: 14px 12px 40px;
  }
  .rg-telemetry-grid {
    grid-template-columns: 1fr;
  }
  .rg-track-header-top {
    flex-direction: column;
    align-items: stretch;
  }
  .rg-trip-select {
    width: 100%;
  }
  .rg-map-controls-strip {
    flex-direction: column;
    align-items: stretch;
  }
  .rg-map-actions {
    width: 100%;
    justify-content: space-between;
  }
  .rg-leaflet-container {
    min-height: 360px;
  }
}
