/* --- Variables de Diseño Conductor PWA (Modo Claro - Legibilidad Alta) --- */
:root {
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', monospace;

  /* Colores */
  --bg-light: #ffffff;
  --bg-app: #fffbf9;            /* Soft warm background */
  --bg-card: rgba(255, 255, 255, 0.95);
  --border-glass: rgba(15, 23, 42, 0.08);

  /* Acentos de Conductor (Coral/Naranja Premium) */
  --primary: #f97316;          /* Orange */
  --primary-light: #ffedd5;    /* Light orange background */
  --primary-dark: #ea580c;     /* Darker orange for text */
  --accent-red: #ef4444;       /* Red accent */
  --color-success: #10b981;    /* Green */
  --color-success-light: #059669;
  --color-danger: #e11d48;
  --color-warning: #d97706;
  --color-muted: #475569;
  --text-main: #0f172a;        /* Slate 900 */
  --text-muted: #334155;       /* Slate 700 - Contraste alto */
}

/* --- Estilos Globales --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  background-color: #f8fafc;    /* Slate 50 */
  color: var(--text-main);
  min-height: 100vh;
  display: block;
  padding: 5.5rem 0 0 280px;    /* Deja espacio para el Sidebar en Desktop */
  overflow-y: auto;
}

.glass-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 10% 10%, rgba(249, 115, 22, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(239, 68, 68, 0.06) 0%, transparent 45%);
  z-index: -1;
  pointer-events: none;
}

/* --- Pantallas/Vistas de la App --- */
.app-screen {
  display: none;
  flex-direction: column;
  padding: 2rem 2rem 5rem 2rem;
  background: transparent;
}

.app-screen.active {
  display: flex;
  animation: slideFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-header {
  margin-bottom: 2rem;
  margin-top: 0.5rem;
}

.app-header h2 {
  font-size: 2.1rem;
  font-weight: 850;
  letter-spacing: -1px;
  color: var(--text-main);
}

.app-header p {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.25rem;
}

/* --- Adaptabilidad y Disposición Premium (Sidebar / Bottom-bar) --- */

/* Escritorio (ancho >= 768px) */
@media (min-width: 768px) {
  .phone-navbar {
    position: fixed;
    left: 0;
    top: 4.5rem;
    width: 280px;
    height: calc(100vh - 4.5rem);
    background: #ffffff;
    border-right: 1px solid var(--border-glass);
    border-top: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 2.5rem 1.5rem;
    box-shadow: 4px 0 25px rgba(15, 23, 42, 0.015);
    z-index: 90;
  }

  .nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.1rem;
    cursor: pointer;
    width: 100%;
    padding: 0.95rem 1.5rem;
    border-radius: 16px;
    font-family: var(--font-sans);
    font-size: 0.98rem;
    font-weight: 700;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
  }

  .nav-tab:hover {
    color: var(--text-main);
    background: rgba(249, 115, 22, 0.04);
  }

  .nav-tab.active {
    color: var(--primary);
    background: rgba(249, 115, 22, 0.08);
  }

  .nav-tab.active .nav-icon {
    transform: scale(1.08);
  }

  .app-screen {
    max-width: 1050px;
    margin: 0 auto;
    padding: 2.5rem 3rem 6rem 3rem;
  }
}

/* Dispositivos Móviles (ancho < 768px) */
@media (max-width: 767px) {
  body {
    padding: 5.5rem 1rem 5.5rem 1rem;
  }

  .phone-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 74px;
    background: #ffffff;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: 0.75rem;
    z-index: 1000;
    box-shadow: 0 -8px 25px rgba(15, 23, 42, 0.04);
  }

  .nav-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    width: 33.3%;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 700;
    transition: color 0.2s ease;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
  }

  .nav-tab.active {
    color: var(--primary);
  }

  .nav-tab.active .nav-icon {
    transform: scale(1.1);
  }

  .app-screen {
    padding: 1.25rem 0.5rem 3rem 0.5rem;
  }
}

/* --- Formulario & Inputs --- */
.form-container {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

input, select {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 12px;
  color: var(--text-main);
  padding: 0.8rem 1.1rem;
  font-size: 0.98rem;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

/* --- Botones --- */
.btn {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 750;
  padding: 0.85rem 1.35rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:active {
  transform: scale(0.97);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 1.1rem 1.5rem;
  font-size: 1.05rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ea580c);
  color: #fff;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
  filter: brightness(1.05);
}

.btn-primary:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-red), #b91c1c);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
  filter: brightness(1.05);
}

.btn-warning {
  background: linear-gradient(135deg, var(--color-warning), #b45309);
  color: #fff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.btn-warning:hover {
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.35);
  filter: brightness(1.05);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-success), var(--color-success-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* --- Panel de Información de Turno --- */
.shift-status-card {
  background: var(--primary-light);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: 18px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.shift-status-icon {
  font-size: 1.75rem;
}

.shift-status-info h4 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.shift-status-info p {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* --- Hoja de Ruta y Asignación de Trabajos --- */
.job-empty-card {
  background: #f8fafc;
  border: 2px dashed rgba(15, 23, 42, 0.1);
  border-radius: 20px;
  padding: 3rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-top: 1rem;
}

.pulse-search-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.5rem;
  animation: pulse-ring 1.8s infinite ease-in-out;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(249, 115, 22, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

.job-card {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 1.25rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.job-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding-bottom: 0.75rem;
}

.job-id {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.job-badge {
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.job-route-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
}

.route-node {
  display: flex;
  flex-direction: column;
}

.node-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
}

.node-name {
  font-size: 1.05rem;
  font-weight: 800;
}

.route-arrow {
  color: var(--text-muted);
  font-size: 1.25rem;
  font-weight: 700;
}

.job-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  background: #f8fafc;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.04);
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.detail-value {
  font-size: 0.92rem;
  font-weight: 800;
}

/* --- Checklist de Inventario del Conductor --- */
.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checklist-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin-top: 0.5rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #ffffff;
  border: 1.5px solid rgba(15, 23, 42, 0.1);
  border-radius: 14px;
  padding: 0.95rem 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.checklist-item:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  background: var(--primary-light);
}

.checklist-item.checked {
  border-color: var(--color-success);
  background: rgba(16, 185, 129, 0.06);
}

.checkbox-custom {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid rgba(15, 23, 42, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: #ffffff;
}

.checklist-item.checked .checkbox-custom {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #ffffff;
}

.checkbox-custom svg {
  display: none;
  width: 14px;
  height: 14px;
  stroke: #ffffff;
  stroke-width: 3px;
  fill: none;
}

.checklist-item.checked .checkbox-custom svg {
  display: block;
}

.checklist-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  user-select: none;
}

/* --- Pantalla de Transito Activo --- */
.transit-status-header {
  background: linear-gradient(135deg, var(--primary), var(--accent-red));
  border-radius: 20px;
  padding: 1.5rem;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.15);
  margin-bottom: 1.25rem;
}

.transit-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transit-status-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.transit-status-badge {
  background: rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.transit-desc {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.3;
}

.transit-battery-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.95;
  margin-top: 0.25rem;
}

.battery-level-fill {
  display: inline-block;
  width: 24px;
  height: 12px;
  border: 1.5px solid #ffffff;
  border-radius: 3px;
  position: relative;
  margin-right: 0.2rem;
}

.battery-level-fill::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  height: 7px;
  background: #ffffff;
  border-radius: 1px;
  transition: width 0.3s;
}

/* Indicadores de ahorro energético */
.eco-saving-banner {
  background: rgba(16, 185, 129, 0.08);
  border: 1.5px solid rgba(16, 185, 129, 0.25);
  border-radius: 14px;
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-success-light);
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.eco-saving-banner svg {
  width: 20px;
  height: 20px;
}

/* Métricas del simulador */
.driver-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.driver-metric-box {
  background: #ffffff;
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.01);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.driver-metric-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.driver-metric-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.driver-metric-val.orange {
  color: var(--primary);
}

.driver-metric-val.green {
  color: var(--color-success-light);
}

.driver-metric-val.red {
  color: var(--color-danger);
}

/* Controles de Simulación (Botonera) */
.transit-controls-card {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 20px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transit-controls-card h4 {
  font-size: 0.95rem;
  font-weight: 800;
}

.control-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Animaciones */
@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Barra de Navegación de Demo Superior --- */
.demo-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  z-index: 999999;
  font-family: 'Outfit', sans-serif;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.demo-logo {
  font-weight: 850;
  font-size: 1.1rem;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.5px;
}

.demo-logo span {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.demo-links {
  display: flex;
  gap: 0.75rem;
}

.demo-link-btn {
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 750;
  color: #475569;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.demo-link-btn:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.04);
}

.demo-link-btn.active-client {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.15);
}

.demo-link-btn.active-driver {
  color: #f97316;
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.15);
}

.demo-link-btn.active-admin {
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.15);
}

@media (max-width: 480px) {
  .demo-top-bar {
    padding: 0 0.75rem;
    height: 54px;
  }
  .demo-logo {
    display: none;
  }
  .demo-links {
    width: 100%;
    justify-content: space-around;
  }
  .demo-link-btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }
}

/* Selector de idioma en el demo bar */
.demo-lang-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.demo-lang-lbl {
  font-size: 0.8rem;
  font-weight: 750;
  color: #475569;
}

.demo-lang-select {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 6px;
  color: #0f172a;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 750;
  font-family: 'Outfit', sans-serif;
  outline: none;
  cursor: pointer;
  width: auto;
}

.demo-lang-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

/* --- Auto-escalamiento responsivo premium (Dispositivos pequeños y viewport de altura reducida) --- */
@media (max-height: 900px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.9);
    transform-origin: center top;
    margin-top: -10px;
    margin-bottom: -70px;
  }
}
@media (max-height: 800px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.8);
    transform-origin: center top;
    margin-top: -50px;
    margin-bottom: -150px;
  }
}
@media (max-height: 700px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.7);
    transform-origin: center top;
    margin-top: -85px;
    margin-bottom: -220px;
  }
}
@media (max-height: 600px) and (min-width: 481px) {
  .phone-frame {
    transform: scale(0.6);
    transform-origin: center top;
    margin-top: -115px;
    margin-bottom: -300px;
  }
}
