* {box-sizing: border-box;}

body {
    margin: 0;
    font-family: system-ui, Arial, sans-serif;
    background: #f2f4f7;
    color: #1f2937;
}
header.barra {
    background: linear-gradient(135deg, #1c8a9a 0%, #1a6ba3 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
header.barra img.logo {
    height: 52px;
    background: white;
    padding: 6px 10px;
    border-radius: 8px;
}
header.barra h1 {
    font-size: 17px;
    margin: 0;
    margin-right: auto;
    font-weight: 600;
}
header.barra a {
    color: #cfe0ff;
    text-decoration: none;
    font-size: 14px;
}
.panel-controles {
    background: white;
    padding: 14px 20px;
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    border-bottom: 1px solid #e2e5ea;
}
.campo {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.campo label { font-weight: 600; color: #374151; }
select, input[type=text], input[type=file], textarea {
    padding: 7px 9px;
    border: 1px solid #cbd2d9;
    border-radius: 6px;
    font-size: 14px;
    min-width: 180px;
}
button {
    background: #1e3a8a;
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
button:hover { background: #16297a; }
button.secundario {
    background: #e5e7eb;
    color: #1f2937;
}
button.secundario:hover { background: #d1d5db; }

button.peligro { background: #b91c1c; }
button.peligro:hover { background: #8f1717; }

#mapa {
    height: calc(100vh - 160px);
    width: 100%;
    background: #dfe3e8;
}
.info-ruta {
    position: absolute;
    top: 170px;
    right: 20px;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    z-index: 1000;
    max-width: 260px;
    font-size: 14px;
}
.pin-ubication span {
    font-size: 22px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
.etiqueta-nodo {
    background: rgba(17,24,39,.75);
    color: white;
    border: none;
    box-shadow: none;
    padding: 0 4px;
    font-size: 10px;
    line-height: 14px;
    border-radius: 3px;
}

.etiqueta-nodo::before { display: none; }

.modo-activo { background: #16a34a !important; }

.leyenda {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: white;
}

.badge.pasillo { background: #6b7280; }
.badge.entrada { background: #059669; }
.badge.escalera { background: #d97706; }

.pin-ubicacion span {
    font-size: 22px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}

.pin-ubicacion.pin-origen span {
    filter: drop-shadow(0 0 3px #16a34a) drop-shadow(0 0 3px #16a34a) drop-shadow(0 0 7px #16a34a);
}

.pin-ubicacion.pin-destino span {
    filter: drop-shadow(0 0 3px #dc2626) drop-shadow(0 0 3px #dc2626) drop-shadow(0 0 7px #dc2626);
}

.campo.buscador { position: relative; }

.resultados-busqueda {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #cbd2d9;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 3000;
    max-height: 260px;
    overflow: auto;
}

.resultados-busqueda div {
    padding: 9px 12px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.resultados-busqueda div:hover { background: #f3f4f6; }

.seleccion {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 13px;
    padding-bottom: 6px;
}

.ayuda { color: #6b7280; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 6px 5px 10px;
    border-radius: 16px;
}

.chip-origen { background: #dcfce7; color: #166534; }
.chip-destino { background: #fee2e2; color: #991b1b; }

.chip button {
    background: transparent;
    color: inherit;
    padding: 0 6px;
    font-size: 14px;
    border-radius: 50%;
}

.chip button:hover { background: rgba(0,0,0,.12); }

.popup-acciones {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.popup-acciones button { flex: 1; }

@media (max-width: 600px) {
    .panel-controles {
        gap: 8px 10px;
        padding: 10px 12px;
    }

    .panel-controles .campo {
        flex: 1 1 42%;
    }

    .panel-controles .campo.buscador {
        flex: 1 1 100%;
    }

    .panel-controles select,
    .panel-controles input[type=text] {
        min-width: 0;
        width: 100%;
    }

    .seleccion {
        flex: 1 1 100%;
        padding-bottom: 0;
    }
}

#mapa.cursor-cruz,
#mapa.cursor-cruz .leaflet-grab,
#mapa.cursor-cruz .leaflet-interactive {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M16 2v28M2 16h28' stroke='white' stroke-width='5' fill='none'/%3E%3Cpath d='M16 2v28M2 16h28' stroke='red' stroke-width='2' fill='none'/%3E%3C/svg%3E") 16 16, crosshair;
}


@media (max-width: 600px) {
  
    body.visor {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        touch-action: pan-x pan-y;
    }

    body.visor #mapa {
        flex: 1;
        height: auto;
        min-height: 0;
        background: #fff;
    }

   
    header.barra {
        padding: 6px 12px;
        gap: 10px;
        flex-wrap: nowrap;
    }

    header.barra img.logo {
        height: 36px;
        padding: 4px 6px;
    }

    header.barra h1 {
        font-size: 15px;
    }

    header.barra a {
        font-size: 12px;
        white-space: nowrap;
    }

    
    .panel-controles {
        padding: 8px 12px;
        gap: 6px 10px;
    }

    .panel-controles .campo {
        flex: 1 1 30%;
        gap: 2px;
    }

    .panel-controles .campo label {
        font-size: 11px;
    }

    .panel-controles .campo.buscador {
        order: 3;
        flex: 1 1 100%;
    }

    .panel-controles .seleccion {
        order: 4;
    }

    .panel-controles select,
    .panel-controles input[type=text] {
        padding: 5px 8px;
    }

    .panel-controles button {
        flex: 0 0 auto;
        padding: 7px 12px;
    }

  
    .info-ruta {
        position: static;
        max-width: none;
        border-radius: 0;
        box-shadow: 0 -2px 8px rgba(0,0,0,.12);
        padding: 8px 12px;
        font-size: 13px;
    }

    .info-ruta br {
        display: none;
    }

    .info-ruta button {
        margin: 4px 0 0 8px !important;
        padding: 6px 10px;
        font-size: 13px;
    }


    .seleccion {
        gap: 6px;
    }

    .chip {
        flex: 1 1 0;
        min-width: 0;
        font-size: 12px;
        padding: 3px 4px 3px 8px;
    }

    .chip b {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.panel-agente { display: none; position: fixed; right: 16px; bottom: 16px; width: 360px; max-width: calc(100vw - 32px); height: 480px; max-height: calc(100dvh - 120px); background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.3); z-index: 2500; flex-direction: column; overflow: hidden; }
.panel-agente.abierto { display: flex; }
.agente-cabecera { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #1a6ba3; color: #fff; }
.agente-cabecera button { background: none; color: #fff; padding: 2px 8px; font-size: 16px; }
.agente-registro { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.agente-msg { max-width: 85%; padding: 8px 10px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; }
.agente-msg-agente { background: #f3f4f6; align-self: flex-start; }
.agente-msg-usuario { background: #1a6ba3; color: #fff; align-self: flex-end; }
.agente-formulario { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #e5e7eb; }
.agente-formulario input { flex: 1; min-width: 0; font-size: 16px; }
@media (max-width: 600px) {
    .panel-agente { right: 0; bottom: 0; width: 100%; max-width: 100%; height: 60dvh; border-radius: 12px 12px 0 0; }
}

.agente-acciones { display: flex; gap: 4px; }
.agente-formulario button.secundario.escuchando { background: #dc2626; color: #fff; }

.burbuja-agente { position: fixed; right: 20px; bottom: 20px; width: 60px; height: 60px; border-radius: 50%; padding: 0; font-size: 28px; line-height: 1; background: #1a6ba3; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.35); z-index: 2400; animation: pulso-agente 2s ease-out 3; }
.burbuja-agente:hover { background: #155a8a; }
.panel-agente.abierto + .burbuja-agente { display: none; }
@keyframes pulso-agente {
    0% { box-shadow: 0 4px 14px rgba(0,0,0,.35), 0 0 0 0 rgba(26,107,163,.6); }
    100% { box-shadow: 0 4px 14px rgba(0,0,0,.35), 0 0 0 22px rgba(26,107,163,0); }
}
@media (max-width: 600px) {
    .burbuja-agente { right: 14px; bottom: 90px; width: 54px; height: 54px; font-size: 26px; }
}

.aviso-agente { position: fixed; right: 92px; bottom: 32px; max-width: 220px; padding: 10px 14px; background: #fff; color: #1f2937; font-size: 14px; border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 2400; opacity: 0; transform: translateX(8px); transition: opacity .3s, transform .3s; pointer-events: none; }
.aviso-agente::after { content: ''; position: absolute; right: -7px; top: 50%; margin-top: -7px; border-width: 7px 0 7px 8px; border-style: solid; border-color: transparent transparent transparent #fff; }
.aviso-agente.visible { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }
.panel-agente.abierto ~ .aviso-agente { display: none; }
@media (max-width: 600px) {
    .aviso-agente { right: 78px; bottom: 98px; }
}

.agente-foto { display: block; width: 100%; border-radius: 8px; }

.navidad-capa { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1500; }
.navidad-regalo { position: absolute; top: -50px; opacity: .9; animation: navidad-caida linear infinite; }
@keyframes navidad-caida {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(55vh) translateX(18px) rotate(180deg); }
    100% { transform: translateY(115vh) translateX(-12px) rotate(360deg); }
}

.seleccion .ayuda { color: #1a4f7a; font-weight: 700; font-size: 14px; }

.direcciones-ruta { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; max-height: 34vh; overflow-y: auto; }
.direcciones-ruta li { padding: 5px 0 5px 10px; border-left: 3px solid #1a6ba3; margin-left: 4px; line-height: 1.35; }
.direcciones-ruta li small { color: #6b7280; }
.direcciones-ruta .dir-inicio { border-left-color: #16a34a; font-weight: 700; }
.direcciones-ruta .dir-fin { border-left-color: #dc2626; font-weight: 700; }
.direcciones-ruta .dir-giro b, .direcciones-ruta .dir-escalera b { color: #1a4f7a; }

.cartel-ayuda { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 2100; align-items: center; justify-content: center; padding: 16px; }
.cartel-ayuda-caja { background: #fff; border-radius: 12px; padding: 20px; max-width: 380px; width: 100%; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
.cartel-ayuda-caja h3 { margin: 0 0 10px; color: #1a4f7a; }
.cartel-ayuda-caja ol { margin: 0 0 14px; padding-left: 20px; font-size: 15px; line-height: 1.6; }
.cartel-ayuda-caja button { width: 100%; padding: 10px; font-size: 16px; }

.aviso-qr { position: fixed; top: 150px; left: 50%; transform: translateX(-50%); z-index: 2200; align-items: center; gap: 12px; background: #166534; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); max-width: min(520px, 92vw); font-size: 15px; line-height: 1.4; }
.aviso-qr button { background: rgba(255, 255, 255, .2); color: #fff; padding: 2px 8px; font-size: 16px; flex-shrink: 0; }

.aviso-qr.aviso-qr-error { background: #92400e; }
