:root {
  --bg-color: #000000;
  --surface-color: #1C1C1E;
  --surface-color-light: #2C2C2E;
  --text-primary: #FFFFFF;
  --text-secondary: #EBEBF5;
  --text-tertiary: rgba(235, 235, 245, 0.6);
  --accent-green: #34C759;
  --accent-blue: #0A84FF;
  --accent-red: #FF3B30;
  --accent-orange: #FF9500;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}
.view { display: none; height: 100%; flex-direction: column; padding: 24px 20px; overflow-y: auto; }
.view.active { display: flex; }
#active-trip-view { padding: 0 !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: 100 !important; overflow: visible !important; }
.hidden { display: none !important; }
.view.active { display: flex; }
#active-trip-view.active { animation: none !important; }

/* Typography */
h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; text-align: center; letter-spacing: -0.5px; }
h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.3px; }
p { font-size: 16px; color: var(--text-secondary); text-align: center; margin-bottom: 24px; line-height: 1.4; }

/* Panels */
.glass-panel {
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  margin: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Inputs & Buttons */
input {
  width: 100%;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-color-light);
  color: var(--text-primary);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
input:focus { 
  border-color: var(--accent-blue); 
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.25);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--bg-color);
  font-weight: 700;
  font-size: 18px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-primary:active { transform: scale(0.95); }

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:active { background: rgba(255,255,255,0.1); transform: scale(0.95); }
.btn-outline.red { border-color: var(--accent-red); color: var(--accent-red); width: 100%; padding: 14px; margin-top: 10px; font-weight: 600; font-size: 16px; }

.error-msg { color: var(--accent-red); font-size: 14px; text-align: center; margin-top: 12px; height: 20px; font-weight: 500;}

/* Dashboard Header */
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-top: env(safe-area-inset-top, 0px); }
.driver-info { display: flex; flex-direction: column; }
.driver-info span { font-size: 14px; color: var(--text-tertiary); font-weight: 500;}

/* Status Toggle */
.status-card {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-color);
  padding: 20px 24px; 
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.status-toggle-wrapper { display: flex; align-items: center; gap: 16px; }
.status-info { display: flex; align-items: center; gap: 12px; }
.indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-red); box-shadow: 0 0 10px var(--accent-red); }
.indicator.on { background: var(--accent-green); box-shadow: 0 0 15px var(--accent-green); }

.switch { position: relative; display: inline-block; width: 52px; height: 32px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--surface-color-light); transition: .3s ease-in-out; }
.slider:before { position: absolute; content: ""; height: 28px; width: 28px; left: 2px; bottom: 2px; background-color: white; transition: .3s cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--accent-green); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }
#status-text { font-weight: 600; font-size: 18px; }

/* Radar */
.radar {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; overflow: hidden; background: transparent; border: none; box-shadow: none;
}
.radar-pulse-container {
  position: relative;
  width: 150px; height: 150px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 30px;
}
.radar-pulse {
  position: absolute;
  width: 100%; height: 100%; 
  background: rgba(52, 199, 89, 0.15);
  border: 1px solid rgba(52, 199, 89, 0.3);
  border-radius: 50%;
  animation: pulse 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.radar-pulse:nth-child(2) { animation-delay: 0.8s; }
.radar-pulse:nth-child(3) { animation-delay: 1.6s; }
.radar-core {
  width: 40px; height: 40px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--accent-green);
  z-index: 10;
}
@keyframes pulse {
  0% { transform: scale(0.3); opacity: 1; }
  80% { opacity: 0; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Alert Overlay (Action Sheet) */
.overlay { 
  position: fixed; top: 0; left: 0; width: 100%; bottom: 0; 
  background: rgba(0,0,0,0.6); z-index: 2000; 
  display: flex; align-items: flex-end; justify-content: center; 
  backdrop-filter: blur(5px);
  transition: opacity 0.3s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.alert-card, .alert-box { 
  background: var(--surface-color); 
  width: 100%; 
  max-height: 85%;
  overflow-y: auto;
  border-radius: 24px 24px 0 0; 
  padding-bottom: env(safe-area-inset-bottom, 20px);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.overlay:not(.hidden) .alert-card, .overlay:not(.hidden) .alert-box { transform: translateY(0); }

.alert-header { 
  background: var(--accent-green); 
  color: var(--bg-color); 
  padding: 16px; 
  text-align: center; 
  font-weight: 800; 
  font-size: 18px; 
  border-radius: 24px 24px 0 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.alert-body { padding: 24px; display: flex; flex-direction: column; align-items: center; }
.alert-distance-badge {
  background: rgba(255,255,255,0.1);
  padding: 6px 12px; border-radius: 20px; font-size: 14px; font-weight: 600; margin-bottom: 16px;
}
.location-highlight { 
  color: var(--text-primary); font-weight: 700; font-size: 22px; margin-bottom: 24px; text-align: center;
  line-height: 1.2;
}

.eta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; margin-bottom: 16px; }
.btn-eta { 
  background: var(--surface-color-light); 
  color: var(--text-primary); 
  border: 1px solid rgba(255,255,255,0.1); 
  padding: 18px; border-radius: var(--radius-sm); 
  font-weight: 700; font-size: 18px; 
  transition: all 0.2s;
}
.btn-eta:active { background: var(--text-primary); color: var(--bg-color); transform: scale(0.95); }

/* Active Trip */
.warning-header { color: var(--text-primary); border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 16px; }
#trip-id-badge { background: var(--surface-color-light); color: var(--text-secondary); padding: 6px 12px; border-radius: 20px; font-weight: 700; font-size: 14px;}

.trip-details { margin-bottom: 16px; padding: 20px; }
.trip-details p { text-align: left; margin-bottom: 16px; font-size: 18px; color: var(--text-primary); }
.trip-details strong { color: var(--text-tertiary); font-size: 14px; display: block; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px;}

.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-action {
  padding: 12px;
  font-size: 0.95rem;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.action-btn span.cmd {
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 400;
  text-transform: none;
}
.btn-action:active { transform: scale(0.95); }
.btn-action.primary { background: var(--accent-blue); grid-column: span 2; padding: 20px; font-size: 20px; }
.btn-action.success { background: var(--accent-green); color: var(--bg-color); }
.btn-action.warning { background: var(--accent-orange); color: var(--bg-color); }
.btn-action.danger { background: var(--surface-color-light); color: var(--accent-red); }
.btn-action.outline { background: transparent; border: 1px solid var(--accent-red); color: var(--accent-red); }

.chat-container { height: 300px; display: flex; flex-direction: column; padding: 16px; border-radius: var(--radius-lg); background: var(--surface-color); overflow: hidden; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; padding-right: 4px; }
.msg { padding: 12px 16px; border-radius: 18px; max-width: 85%; word-wrap: break-word; font-size: 15px; line-height: 1.4; flex-shrink: 0; }
.msg.client { background: var(--surface-color-light); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.driver { background: var(--accent-blue); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-input-area {
  display: flex;
  padding: 10px;
  background-color: var(--card-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.chat-input-area input {
  flex: 1;
  padding: 10px 15px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  outline: none;
}

.btn-send, .btn-record, .btn-attach {
  background-color: var(--primary);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

.btn-record {
  background-color: rgba(255,255,255,0.1);
}
.btn-record.recording {
  background-color: var(--danger);
  animation: pulse 1.5s infinite;
}

.btn-attach {
  background-color: rgba(255,255,255,0.15);
}

.btn-send svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  transform: translateX(-1px);
}

.star-rating {
  display: flex;
  gap: 5px;
  font-size: 2rem;
  color: #555;
  cursor: pointer;
}
.star-rating span:hover,
.star-rating span.active {
  color: #FFD700;
}
.btn-send svg { width: 20px; height: 20px; fill: currentColor; }

/* Scrollbar styling for chat */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

/* New overlays for waiting and cost */
.waiting-box { text-align: center; }
.spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  width: 40px; height: 40px;
  border-radius: 50%;
  border-left-color: var(--primary);
  animation: spin 1s linear infinite;
  margin: 0 auto 15px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.cost-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 15px;
  margin-top: 15px;
  font-size: 1.5rem;
}
.cost-input-wrapper span {
  color: var(--text-secondary);
  margin-right: 10px;
}
.cost-input-wrapper input {
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  width: 100%;
  outline: none;
}

/* Leaflet Map Styles */
.leaflet-routing-container {
  display: none !important; /* Hide routing instructions */
}

/* REDESIGNED DRIVER UI (InDrive/Uber Style) */
#trip-map {
  position: absolute !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 0 !important;
  margin: 0 !important;
  background: #e5e7eb !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.top-hud {
  position: absolute;
  top: env(safe-area-inset-top, 20px);
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
}

#trip-id-badge {
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  backdrop-filter: blur(5px);
}

.btn-sos-floating {
  position: absolute;
  top: env(safe-area-inset-top, 15px);
  right: 15px;
  width: 32px !important;
  height: 32px !important;
  background: var(--accent-red);
  color: white;
  z-index: 1000;
  border: none;
  border-radius: 50%;
  display: flex; justify-content: center; align-items: center;
}

.bottom-sheet-container.style-indrive {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-color);
  border-radius: 20px 20px 0 0;
  padding: 8px 14px 16px 14px !important;
  z-index: 1001 !important;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 40vh;
  overflow-y: auto;
}

.bottom-sheet-handle {
  width: 36px;
  height: 3px;
  background: var(--text-tertiary);
  border-radius: 3px;
  margin: 0 auto 2px auto;
  opacity: 0.4;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.location-header {
  display: flex;
  gap: 12px;
  align-items: center;
  max-width: 80%;
}

.loc-icon {
  color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.15);
  padding: 8px;
  border-radius: 50%;
  display: flex;
}

.loc-address {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-distance {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 0;
}

.client-profile {
  display: flex;
  gap: 12px;
  align-items: center;
}

.avatar {
  background: rgba(255,255,255,0.1);
  padding: 8px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
}

#active-client-name {
  margin: 0 0 2px 0;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.text-success { color: var(--accent-green) !important; }
.text-warning { color: var(--accent-orange) !important; }
.text-danger { color: var(--accent-red) !important; }
.text-sm { font-size: 0.85rem; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

.client-actions {
  display: flex;
  gap: 10px;
}

.btn-circular {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s;
}
.btn-circular:active { transform: scale(0.9); }

.bg-blue { background: var(--accent-blue); }
.text-white { color: white; }
.bg-light { background: rgba(255,255,255,0.1); }
.text-primary { color: var(--text-primary); }
.shadow { box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.ml-2 { margin-left: 10px; }

.btn-main-action {
  flex: 1;
  height: 44px;
  padding: 8px 16px;
  border-radius: 22px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s;
}
.btn-main-action:active { transform: scale(0.98); }

.icon-circle {
  background: rgba(255,255,255,0.2);
  padding: 4px;
  border-radius: 50%;
  display: flex;
}

/* Chat overlay */
.chat-overlay-sheet {
  background: rgba(0,0,0,0.2);
  border-radius: 16px;
  padding: 10px;
  margin-top: -5px;
  margin-bottom: 5px;
  height: 200px;
  display: flex;
  flex-direction: column;
}
.compact-chat { flex: 1; height: 100%; min-height: 0; margin-bottom: 10px; }
.compact-input { padding: 0; background: transparent; }

/* Options menu */
.options-menu-sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 5px;
}
.btn-option {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.05);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 15px;
  color: var(--text-primary);
}
.btn-option:active { opacity: 0.8; }


/* More time preset buttons */
.btn-time-preset.active {
  background: var(--accent-blue) !important;
  color: white !important;
}
.btn-time-preset:active { opacity: 0.8; }

/* Smooth Real-Time Taxi Icon & Navigation */
.smooth-taxi-marker {
  transition: transform 1.2s cubic-bezier(0.25, 0.1, 0.25, 1) !important;
  will-change: transform;
  border: none !important;
  background: transparent !important;
}
.car-rotation-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 70px;
  transition: transform 0.4s ease-out;
  transform-origin: center center;
  will-change: transform;
}
.car-rotation-container svg {
  pointer-events: none;
}
.client-pickup-marker {
  background: transparent !important;
  border: none !important;
}
.pickup-pin-wrapper {
  position: relative;
  width: 36px;
  height: 46px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.pickup-pulse {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.4);
  animation: pickupPulseAnim 1.8s infinite;
  pointer-events: none;
}
@keyframes pickupPulseAnim {
  0% { transform: translateX(-50%) scale(0.6); opacity: 1; }
  100% { transform: translateX(-50%) scale(2.4); opacity: 0; }
}
.pickup-pin {
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

/* Botones rápidos de navegación Maps & Waze */
.btn-nav-quick {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
  font-size: 9.5px;
  font-weight: 700;
  gap: 1px;
}
.btn-nav-quick:active {
  transform: scale(0.92);
}

/* Botones compactos de acciones de recogida en 1 sola fila */
.btn-arrived-action {
  width: 100%;
  padding: 8px 6px;
  border-radius: 10px;
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  height: 38px;
  transition: all 0.25s ease;
  box-shadow: 0 3px 10px rgba(22, 163, 74, 0.35);
  white-space: nowrap;
}
.btn-arrived-action:active {
  transform: scale(0.97);
}
.btn-arrived-action.avisado {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35);
}
.btn-arrived-action.reenviar {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 3px 10px rgba(217, 119, 6, 0.35);
}

.btn-quick-action {
  width: 100%;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  height: 38px;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.btn-quick-action:active {
  transform: scale(0.97);
}

.btn-quick-time {
  background: rgba(245, 158, 11, 0.16);
  border: 1.5px solid #f59e0b;
  color: #fbbf24;
}

.btn-quick-cancel {
  background: rgba(239, 68, 68, 0.16);
  border: 1.5px solid #ef4444;
  color: #f87171;
}

