:root {
    --petrol: #0F5C5C;
    --petrol-oscuro: #0A3D3D;
    --petrol-claro: #3D8B8B;
    --amber: #F5A623;
    --amber-oscuro: #D6890C;
    --crema: #FAF8F5;
    --tinta: #17211F;
    --gris: #6B7674;
    --linea: #E4E0D8;
    --exito: #2F9E44;
    --peligro: #E03131;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; font-family: 'Inter', system-ui, sans-serif; color: var(--tinta); background: var(--crema); }
h1, h2, .marca-chica { font-family: 'Space Grotesk', sans-serif; }
.oculto { display: none !important; }
.pantalla { min-height: 100%; }

/* ---- Auth ---- */
#pantalla-auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-contenedor { width: 100%; max-width: 380px; text-align: center; }
.auth-contenedor h1 { font-size: 24px; margin: 14px 0 2px; color: var(--petrol-oscuro); font-weight: 500; }
.auth-contenedor h1 strong { font-weight: 700; }
.subtitulo { color: var(--gris); margin: 0 0 22px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
    padding: 13px 14px; border-radius: 12px; border: 1px solid var(--linea);
    font-size: 15px; font-family: inherit; background: white;
}
.auth-form input:focus { outline: none; border-color: var(--petrol-claro); }
.error { color: var(--peligro); font-size: 13px; margin-top: 12px; min-height: 16px; }

.btn { border: none; border-radius: 12px; padding: 13px 18px; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primario { background: var(--petrol); color: white; }
.btn-primario:hover { background: var(--petrol-oscuro); }
.btn-primario:disabled { opacity: 0.6; cursor: default; }
.btn-texto { background: none; color: var(--gris); padding: 8px 10px; }
.btn-texto:hover { color: var(--tinta); }

/* ---- Panel principal ---- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: var(--petrol); color: white;
    position: sticky; top: 0; z-index: 10;
}
.marca-chica { font-size: 16px; }
.marca-chica strong { font-weight: 700; }
.topbar .btn-texto { color: rgba(255,255,255,0.85); }
.topbar .btn-texto:hover { color: white; }

.contenido { max-width: 640px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.tarjeta { background: white; border-radius: 16px; padding: 20px; border: 1px solid var(--linea); }
.tarjeta h2 { font-size: 17px; margin: 0 0 16px; color: var(--petrol-oscuro); }
.tarjeta-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.tarjeta-header h2 { margin: 0; }

/* ---- Pantalla principal: mapa de fondo a pantalla completa ---- */
#pantalla-panel { position: fixed; inset: 0; overflow: hidden; }
html, body:has(#pantalla-panel:not(.oculto)) { overflow: hidden; }

.mapa-fondo { position: absolute; inset: 0; z-index: 0; }
#mapa-choferes.mapa-fondo { height: 100%; width: 100%; }

.vacio-flotante {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 5; background: white; padding: 14px 20px; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12); font-size: 13px; color: var(--gris); text-align: center;
}

.leyenda-flotante {
    position: absolute; bottom: 18px; left: 18px; z-index: 10;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(4px);
    border-radius: 12px; padding: 9px 14px; display: flex; gap: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.leyenda-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gris); }
.leyenda-item .punto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.punto-online { background: var(--petrol); }
.punto-ocupado { background: var(--amber); }
.punto-offline { background: var(--peligro); }

/* ---- Menú vertical flotante (lateral derecho, colapsable) ---- */
.btn-toggle-menu {
    position: absolute; top: 16px; right: 16px; z-index: 30;
    width: 44px; height: 44px; border-radius: 12px; border: none;
    background: var(--petrol); color: white; font-size: 18px; cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.btn-toggle-menu:hover { background: var(--petrol-oscuro); }

.menu-vertical {
    position: absolute; top: 16px; right: 16px; z-index: 28;
    background: rgba(255,255,255,0.97); backdrop-filter: blur(6px);
    border-radius: 16px; padding: 62px 14px 14px; width: 190px;
    display: flex; flex-direction: column; gap: 8px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.16);
    transform: translateX(230px); opacity: 0; pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.menu-vertical.abierto { transform: translateX(0); opacity: 1; pointer-events: auto; }

.menu-vertical-titulo { position: absolute; top: 16px; left: 16px; font-size: 15px; color: var(--petrol-oscuro); }
.menu-vertical-titulo strong { font-weight: 700; }

.btn-menu-vertical {
    background: var(--crema); color: var(--tinta); border: 1px solid var(--linea);
    border-radius: 10px; padding: 11px 12px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit; text-align: left;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.btn-menu-vertical .atajo {
    font-size: 11px; font-weight: 700; color: var(--gris); background: white;
    border: 1px solid var(--linea); border-radius: 5px; padding: 1px 6px;
}
.btn-menu-vertical:hover { background: var(--linea); }
.btn-menu-vertical.activo { background: var(--petrol); color: white; border-color: var(--petrol); }
.btn-menu-salir { color: var(--peligro); margin-top: 6px; border-top: 1px solid var(--linea); border-radius: 10px; }
.btn-menu-salir:hover { background: #FBEAEA; }

/* ---- Fondo oscuro + paneles flotantes ---- */
.backdrop {
    position: absolute; inset: 0; background: rgba(10, 20, 20, 0.35); z-index: 25;
}

.panel-flotante {
    position: absolute; top: 16px; left: 16px; right: 16px; margin: 0 auto;
    max-width: 420px; max-height: calc(100% - 32px); overflow-y: auto;
    background: white; border-radius: 18px; padding: 20px; z-index: 32;
    box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}
@media (min-width: 640px) {
    .panel-flotante { left: auto; right: 20px; margin: 0; }
}

.panel-flotante-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-flotante-header h2 { margin: 0; font-size: 17px; color: var(--petrol-oscuro); }
.btn-cerrar-panel {
    background: none; border: none; font-size: 22px; line-height: 1; color: var(--gris);
    cursor: pointer; padding: 2px 6px;
}
.btn-cerrar-panel:hover { color: var(--tinta); }

#mapa-choferes { height: 380px; }
.popup-chofer { font-family: 'Inter', system-ui, sans-serif; font-size: 13px; }
.popup-chofer strong { display: block; font-size: 14px; margin-bottom: 3px; }
.popup-chofer .popup-estado { font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }
.popup-chofer .popup-estado.online { color: var(--exito); }
.popup-chofer .popup-estado.ocupado { color: var(--amber-oscuro); }
.popup-chofer .popup-estado.offline { color: var(--peligro); }
.popup-chofer .popup-tiempo { color: var(--gris); font-size: 12px; margin-top: 2px; }

#form-nuevo-viaje { display: flex; flex-direction: column; gap: 6px; }
#form-nuevo-viaje label { font-size: 12px; color: var(--gris); margin-top: 8px; font-weight: 600; }
#form-nuevo-viaje input {
    padding: 12px 14px; border-radius: 10px; border: 1px solid var(--linea);
    font-size: 14px; font-family: inherit; width: 100%;
}
#form-nuevo-viaje input:focus { outline: none; border-color: var(--petrol-claro); }
#form-nuevo-viaje button { margin-top: 16px; }

.campo-autocomplete { position: relative; }
.lista-sugerencias {
    list-style: none; margin: 4px 0 0; padding: 4px; position: absolute; top: 100%; left: 0; right: 0;
    background: white; border: 1px solid var(--linea); border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    max-height: 220px; overflow-y: auto; z-index: 20;
}
.lista-sugerencias li { padding: 10px 12px; font-size: 13px; border-radius: 6px; cursor: pointer; }
.lista-sugerencias li:hover { background: var(--crema); }

.mensaje { margin-top: 12px; font-size: 13px; padding: 10px 12px; border-radius: 10px; }
.mensaje.ok { background: #EAF6EC; color: var(--exito); }
.mensaje.error { background: #FBEAEA; color: var(--peligro); }

.lista-viajes { display: flex; flex-direction: column; gap: 10px; }
.vacio { color: var(--gris); font-size: 14px; text-align: center; padding: 12px 0; }
.item-viaje { border: 1px solid var(--linea); border-radius: 12px; padding: 12px 14px; }
.item-viaje-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.item-viaje-direccion { font-weight: 600; font-size: 14px; }
.badge { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.badge-buscando { background: #FFF3DE; color: var(--amber-oscuro); }
.badge-asignado { background: #E4F0F0; color: var(--petrol); }
.badge-curso { background: #FFF3DE; color: var(--amber-oscuro); }
.badge-finalizado { background: #EAF6EC; color: var(--exito); }
.badge-sinchoferes { background: #FBEAEA; color: var(--peligro); }
.item-viaje-detalle { font-size: 12.5px; color: var(--gris); margin-top: 6px; }
.item-viaje-acciones { display: flex; gap: 8px; margin-top: 10px; }
.btn-chico {
    flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--linea);
    background: white; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-reasignar { color: var(--petrol); border-color: var(--petrol-claro); }
.btn-reasignar:hover { background: var(--crema); }
.btn-cancelar-viaje { color: var(--peligro); border-color: var(--peligro); }
.btn-cancelar-viaje:hover { background: #FBEAEA; }
