html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

/* =========================
        Theme variables 
   ========================= */
:root {
    /* Core backgrounds */
    --background-color: #f9f9f9;
    --bg-primary: #5a001f;
    --bg-secondary: #ffffff; 
    --bg-primary-readeable: #4b001a;

    /* Text */
    --text-primary: #000000;
    --text-secondary: #333333;
    --text-muted: rgba(33,37,41,0.75); 
    --text-inverted: #ffffff;

    /* Special/title/button colors */
    --title-secondary-text: #ececec; /* used as requested for headerButtons & #marcarMensaje backgrounds */
    --button-text: #5b0000;; 

    /* Inputs */
    --input-bg: #ffffff;
    --input-border: #cccccc;
    --input-text: #000000;

    /* Routes / list items */
    --route-item-bg: #f5f5f5;
    --route-item-hover-bg: #e0e0e0;

    /* Sidebar */
    --sidebar-bg: #ffffff;
    --sidebar-header-bg: #1976d2;
    --sidebar-header-text: var(--text-inverted);
    --sidebar-nav-bg: #f5f5f5;
    --sidebar-nav-btn-bg: #e0e0e0;
    --sidebar-nav-btn-text: var(--text-primary);

    /* Alerts */
    --alert-info-bg: #e8f5ff;
    --alert-info-border: #2196f3;
    --alert-warn-bg: #fff8e1;
    --alert-warn-border: #ffb300;
    --alert-error-bg: #fff0f0;
    --alert-error-border: #e53935;

    /* Danger */
    --danger-bg: #c33;
    --danger-text: #ffffff;

    /* Shadows & overlays */
    --box-shadow-strong: 0 2px 6px rgba(0,0,0,0.3);
    --box-shadow-soft: 0 -4px 12px rgba(0,0,0,0.3);
    --overlay-bg: rgba(0,0,0,0.4);

    /* Scrollbar */
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #b0b0b0;

    /* Misc */
    --mix-hover: color-mix(in srgb, var(--bg-primary) 90%, white 10%);

    /* --- Primary Blue Variations --- */
    --blue-light: #63a4ff;   /* Para hover o fondos claros */
    --blue: #1976d2;         /* Color base */
    --blue-dark: #004ba0;    /* Para estados activos o bordes */

    /* --- Semantic / Status Colors (Mismo peso visual) --- */
    --red: #d32f2f;          /* Error / Peligro */
    --green: #388e3c;        /* Éxito / Confirmación */
    --orange: #f57c00;       /* Alerta / Acción secundaria */
    --yellow: #fbc02d;       /* Advertencia */

    /* --- Accents --- */
    --purple: #7b1fa2;
    --teal: #00796b;

    /* --- Neutrals & Text --- */
    --black-light: #212121;    /* Almost black */
    --grey-hard: #757575;   /* Texto secundario */
    --grey-light: #f5f5f5;   /* Fondos de sección */
    --grey-border: #e0e0e0;  /* Bordes sutiles */
    --white: #ffffff;
}

/* font */
@font-face {
    font-family: "Hornbill";
    src: url("../fonts/hornbill.otf") format("opentype");
    font-weight: bold;
    font-style: bold;
}

/* Suggestions */
.suggestions {
    /* position: absolute; */
    display: flex;
    width: 100%;
    /* margin: 1vh; */
    /* left: 0; */
    /* right: 0; */
    /* bottom: 100%; */
    background: var(--bg-secondary);
    max-height: 10vh;
    /* width: max-content; */
    overflow-y: auto;
    z-index: 1000;
    flex-direction: column;
    align-content: flex-start;
    align-items: flex-start;
    justify-content: center;
}

.suggestions div {
    padding: 5px 10px;
    cursor: pointer;
}

.suggestions div:hover {

    color: var(--bg-primary);
}

.link-clean {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.link-clean:visited,
.link-clean:active,
.link-clean:hover {
    color: inherit;
    text-decoration: none;
}

.smallSpan {
    color: var(--text-muted);
    font-size: smaller;
}

.centerFlex,
*>.centerFlex,
*>*>.centerFlex {
    display: flex;
    justify-content: center;
}

.rotateInfinite {
    display: inline-block;
    animation: rotateLoop 1.5s linear infinite;
}

@keyframes rotateLoop {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

div.panel-header>h3,
div#routesHeader>h3,
#titleMainH {
    font-family: "Hornbill", sans-serif;
    margin: 0.125em;
    font-size: smaller;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Main title bar */

.mainBar {
    position: absolute;
    display: flex;
    /* flex-wrap: wrap; */
    left: 0;
    
    width: -moz-available;
    width: -webkit-fill-available;
    background: var(--bg-primary);
    color: var(--text-inverted);
    font-size: 18px;
    text-align: center;
    padding: 12px 25px;
    z-index: 30;
    box-shadow: var(--box-shadow-strong);
    align-items: flex-start;
    pointer-events: none;
    z-index: 500;
}

.mainBar * {
    pointer-events: auto;
}

.mainBar.top {
    top: 0;
    background: unset;
    justify-content: space-between;
    box-shadow: none;
}

.mainBar.top > div > div.center-logo {
    background: var(--bg-primary);
    color: var(--text-inverted);
    padding: 0.1vh 0.5vh 0.1vh 0.5vh;
    border-radius: 1vh;
}

.mainBar.top > div > div.buttons, .mainBar.buttom-alt > div > div.buttons
,.maplibregl-ctrl-group 
{
    display: flex;
    flex-direction: column;
    gap: 1vh;
    flex-wrap: wrap;
}

.mainBar.top > div > div.buttons > button, .mainBar.buttom-alt > div[data-section="right"] > div.buttons > button {
    height: 4.5vh;
    width: 4.5vh;
}

.mainBar.top > div > div.buttons > button, .mainBar.buttom-alt > div > div.buttons > button

{
    background: var(--bg-secondary);
    color: var(--bg-primary-readeable);
    border: none;
    border-radius: 5vh;
    /* width: 4vh;
    height: 4vh; */
    /* padding: 1.5vh 1.5vh 1.5vh 1.5vh; */

    box-shadow: var(--box-shadow-strong);

    cursor: pointer;
    font-size: smaller;
    transition: all 0.3s ease;
}

.mainBar.top > div > div.buttons > button:hover, .mainBar.buttom-alt > div > div.buttons > button:hover, .maplibregl-ctrl-icon:hover {
    background: var(--bg-primary);
    color: var(--bg-primary-readeable);
}

/* */

.mainBar.buttom-alt {
    bottom: 0;
    background: unset;
    justify-content: space-between;
    box-shadow: none;
    align-items: flex-end;
}


.mainBar.buttom-alt > div > div.buttons > button {
    display: flex;
    flex-direction: column;
    gap: 1vh;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}


.mainBar.buttom-alt > div[data-section="left"] > div > button {
    padding: 1.1vh 2vh 1.1vh 2vh;
    flex-direction: row;
    align-items: center;
}

.mainBar.buttom-alt > div[data-class-buttons-control="right"] {
    display: flex;
    justify-content: center;
    flex-direction: column-reverse;
    gap: 1vh;
    align-items: center;
}

/* --- */

.mainBar.buttom {
    bottom: 0;
    padding: 0em 1em;
    justify-content: space-around;
}

.iconNavegator {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.5vh;
    margin: 1vh;
    flex-direction: column;
    width: 100%;
    border-radius: 1vh;
    transition: color 0.25s ease, background-color 0.25s ease;
}

.iconNavegator.selected {
    color: var(--bg-primary);
    background-color: var(--bg-secondary);
}

.iconNavegator > h3 {
    font-size: xx-small;
    padding: 0;
    margin: 0.35em;
}

.iconNavegator > icon {
    font-size: larger;
}

/* Control panel */
#controlPanel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    z-index: 20;
    pointer-events: auto;
    transition: bottom 0.3s ease-in-out;
    z-index: 1100;
}

#AllheaderSearch {
    overflow: hidden;
}

.resizable-toucharea {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: ns-resize;
}

.instruccion-item>b {
    font-style: italic;
    font-size: larger;
}

/* search section / bottom panel */
#searchSection,
#SOTAM {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: var(--box-shadow-soft);
    max-height: 65%;
    overflow-y: auto;
}

/* dirigirme top bar */
#dirigirmeTopBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
    color: var(--text-inverted);
    padding: 12px 16px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    flex-shrink: 0;
}

#dirigirmeTopBar span {
    font-weight: bold;
    font-size: 16px;
}

#dirigirmeTopBar button {
    background: var(--bg-secondary);
    color: var(--bg-primary);
    border: none;
    border-radius: 10px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#dirigirmeTopBar button:hover {
    transform: scale(1.05);
    background: var(--mix-hover);
}

/* search row layout */
.btnsSearchRowAlt {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1vh;
}

.searchRow {
    display: flex;
    gap: 1vh;
    flex-wrap: wrap;
    padding: 1.5vh 1vh 1.5vh 1vh;
    margin: 1vh;
    border: 0.1vh solid rgba(33,37,41,0.4);
    border-radius: 2vh;

    flex-direction: row;
    flex-wrap: nowrap;
}

.searchRow input {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--input-text);
}

.searchRow button, .btnsSearchRowAlt.altAlert button {
    padding: 10px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-inverted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.searchRow button:hover {
    transform: scale(1.05);
    background: var(--bg-primary);
}

#btnDirigirme {
    background: var(--bg-primary);
    color: var(--text-inverted);
    padding: 12px;
    font-size: 16px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 8px 16px;
    width: -webkit-fill-available;
    width: -moz-available;
}

#btnDirigirme:hover {
    transform: scale(1.01);
    background: var(--mix-hover);
}

/* marcarMensaje */
#marcarMensaje {
    text-align: center;
    font-weight: bold;
    color: var(--bg-primary-readeable);
    margin: 3vh;
    display: flex;
    gap: 1vh;
    flex-direction: column;
}

/* routes panel and lists */
#routesPanel,
#RutasEncontradas,
#RutasInstrucciones,
#comingsoonPanel,
#MA {
    display: flex;
    flex-direction: column;
    max-height: 25em;
    background: var(--bg-secondary);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: var(--box-shadow-soft);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 28;
}

#routesPanel.visible {
    display: flex;
}

#routesHeader,
#comingsoonHeader,
.panel-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* background: var(--bg-primary); */
    background: var(--bg-secondary);;
    /* color: var(--text-inverted); */
    padding: 0.3em 1em 0em 1em;
    border-top-left-radius: 1em;
    border-top-right-radius: 1em;
    flex-shrink: 20;
    justify-content: space-around;
    flex-wrap: wrap;
    justify-content: center;
}

.headerButtons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1vh;
}

.dragMinimalistIcon {
    width: 5vh;
    height: .85vh;
    background-color: var(--text-secondary);
    border-radius: 10em;
    opacity: 50%;
}

/* IMPORTANT: these two selectors use the title-secondary-text background and button-text color as requested */
.headerButtons button,
#marcarMensaje button {
    background: var(--title-secondary-text);
    color: var(--button-text);
    border: none;
    border-radius: 10px;
    margin-left: 6px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;

    /* IMPORTANT: allow touch & selection where originally forced */
    touch-action: auto !important;
    -webkit-user-select: auto !important;
    user-select: auto !important;
}

.headerButtons button.danger,
#marcarMensaje button.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.headerButtons button:hover,
#marcarMensaje button:hover {
    transform: scale(1.05);
    background: color-mix(in srgb, white 90%, var(--bg-primary) 10%);
}


/* --- Estructura Principal --- */
.panel-list {
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    max-height: calc(75% - 60px);
    /* Scrollbar para navegadores que lo soporten via var */
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#routesList {
    padding: 5px;
    overflow: auto;
}

.routes-scroll-area {
    /* Opcional si se requiere scroll interno */
}

/* --- Botones Globales y Controles --- */
.routes-controls-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    padding: 1vh;
    margin: 0.4vh;
    border-radius: 2vh;
}

.btn-global-toggle {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--grey-border); /* Antes #ddd */
    background: var(--grey-light); /* Antes #f8f9fa */
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: var(--text-secondary); /* Antes #555 */
}

.btn-global-toggle:hover {
    background: var(--route-item-hover-bg); /* Antes #e9ecef */
}

.buttons-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-global-action {
    border: none;
    background: var(--bg-secondary); /* Antes #fff */
    border-radius: 4px;
    padding: 6px 4px;
    font-size: 12px;
    color: var(--text-secondary); /* Antes #555 */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.btn-global-action:hover {
    background: var(--bg-primary); /* Antes #f0f0f0 */
    color: var(--text-primary); /* Antes #333 */
    border: 1px solid var(--grey-border);
}

/* --- Input de Búsqueda --- */
.search-box-container {
    position: relative;
    margin-bottom: 8px;
}

.search-box-container input {
    width: -webkit-fill-available; /* Nota: Propiedad no estándar, pero mantenida */
    width: 100%; /* Fallback estándar */
    box-sizing: border-box;
    padding: 8px 30px;
    border: 1px solid var(--grey-border); /* Antes #ddd */
    border-radius: 20px;
    background: var(--bg-secondary); /* Antes #f8f9fa */
    outline: none;
    font-size: 13px;
    color: var(--input-text);
    transition: all 0.2s;
}

.search-box-container input:focus {
    background: var(--input-bg); /* Antes #fff */
    border-color: var(--input-border); /* Antes #aaa - usé input-border #ccc */
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05); /* Mantenido manual por sutileza */
}

.search-icon, 
.clear-search {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-hard); /* Antes #999 */
    font-size: 12px;
}

.search-icon { left: 10px; }
.clear-search { right: 10px; }

/* --- Grupo de Ruta --- */
.route-group.extended {
    margin-bottom: 8px;
    background: var(--bg-secondary); /* Corregido: Antes bg-primary (rojo), debe ser blanco */
    border: 1px solid var(--grey-border); /* Antes input-border (#ccc), grey-border es más suave (#e0e0e0) */
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* Shadows vars son muy fuertes (0.3), mantengo manual */
    transition: box-shadow 0.2s;
}

.route-group.extended:hover {
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}

/* --- Header de Ruta --- */
.route-header {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-secondary);
    cursor: pointer;
    min-height: 40px;
}

.route-color-bar {
    width: 4px;
    height: 28px;
    border-radius: 2px;
    margin-right: 10px;
    flex-shrink: 0;
}

.route-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding-right: 5px;
}

.route-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

.route-subtitle {
    font-size: 11px;
    color: var(--grey-hard); /* Antes text-secondary (#333), grey-hard (#757575) es mejor para subtítulos */
    margin-top: 2px;
}

/* --- Acciones --- */
.route-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Botones Iconos */
.btn-icon {
    border: none;
    background: transparent;
    color: var(--grey-hard); /* Antes #888 */
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--grey-light); /* Antes #f0f0f0 */
    color: var(--text-secondary); /* Antes #333 */
}

.btn-icon.btn-paradero.active {
    color: var(--blue); /* Antes #1976d2 */
}

.btn-icon.btn-paradero:not(.active) {
    color: var(--input-border); /* Antes #ccc */
}

.btn-icon.small {
    font-size: 12px;
    padding: 2px 5px;
}

/* Estrella Favorito */
.btn-fav {
    color: var(--grey-border); /* Antes #ddd */
    cursor: pointer;
    transition: color 0.2s;
    font-size: 14px;
    padding: 2px;
}

.btn-fav.is-fav {
    color: var(--yellow); /* Antes #ffc107 */
}

.btn-fav:hover {
    color: var(--alert-warn-border); /* Alternativa para hover amarillo un poco más oscuro */
}

/* Checkbox y Collapse */
.cb-group, .cb-route {
    transform: scale(1.2);
    cursor: pointer;
    margin: 0;
    /* Podrías usar accent-color si deseas forzar el color del navegador */
    accent-color: var(--blue); 
}

.toggle-collapse {
    color: var(--grey-hard); /* Antes #999 */
    font-size: 12px;
    margin-left: 2px;
    width: 14px;
    text-align: center;
}

/* --- Variantes (Lista) --- */
.route-variants {
    background: var(--bg-secondary);
    border-top: 1px solid var(--grey-border);
}

.route-item {
    display: flex;
    align-items: center;
    padding: 8px 10px 8px 24px;
    border-bottom: 1px solid var(--grey-border); /* Antes input-border */
    font-size: 13px;
}

.route-item:last-child {
    border-bottom: none;
}

.item-text {
    flex-grow: 1;
    color: var(--text-secondary); /* Antes #444 */
}

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



/* route item */
.route-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--route-item-bg);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.route-item:hover {
    background: var(--route-item-hover-bg);
    transform: translateX(3px);
}

.route-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.route-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.route-text .title {
    font-weight: bold;
    font-size: 14px;
}

.route-text .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.route-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.route-item input[type="checkbox"]:hover {
    transform: scale(1.2);
}

.hidden {
    display: none !important;
}

/* responsive adjustments (part 1) */
@media (max-width:480px) {
    #dirigirmeTopBar {
        font-size: 14px;
        padding: 8px 10px;
    }

    #dirigirmeTopBar button {
        padding: 5px 10px;
        font-size: 13px;
    }

    .searchRow input {
        font-size: 13px;
        padding: 8px;
    }

    .searchRow button {
        font-size: 13px;
        padding: 8px;
    }

    #btnDirigirme {
        font-size: 15px;
        padding: 10px;
    }

    .route-item {
        padding: 6px 8px;
    }

    .route-text .title {
        font-size: 13px;
    }

    .route-text .subtitle {
        font-size: 11px;
    }

    #routesList {
        max-height: 60%;
    }

    #searchSection {
        max-height: 60%;
    }
}

/* milaburger and navbar icons */
.milaburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.milaburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-inverted);
    border-radius: 2px;
}

.btnNavBar {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.btnNavBar span {
    display: block;
    width: 100%;
    height: 3px;
    background: var(--text-inverted);
    border-radius: 2px;
}

/* overlay */
#sidebarOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 10000;
    transition: opacity 0.3s ease;
}

/* sidebar panel */
#sidebarPanel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 50%;
    max-width: 90%;
    height: 100%;
    background-color: var(--sidebar-bg);
    box-shadow: -4px 0 12px rgba(0,0,0,0.2);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    transition: left 0.3s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#sidebarPanel.showAnimation {
    left: 0vh;
}

.sidebarHeader {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1em 2em;
    background-color: var(--sidebar-header-bg);
    color: var(--sidebar-header-text);
    font-weight: bold;
    font-size: 1.2em;
}

.sidebarHeader h3 {
    margin: 0;
    text-align: center;
    flex: 1;
}

#btnCloseSidebar,
.btnCloseConfig {
    position: absolute;
    top: 0.5em;
    left: 0.5em;
    background: none;
    border: none;
    color: var(--sidebar-header-text);
    font-size: 1.6em;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

#btnCloseSidebar:hover {
    color: #ffeb3b; /* accent — kept as a direct color to preserve contrast for close button */
}

/* xd */

.btnCloseConfig {
    left: unset;
    right: 0.5em;
}

/* Navigation Buttons inside Sidebar */
.sidebarNav {
    display: flex;
    justify-content: space-around;
    padding: 0.8em 1em;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    background-color: var(--sidebar-nav-bg);
    overflow: auto;
}

.sidebarNav button {
    flex: 1;
    margin: 0 0.3em;
    padding: 0.6em 0.8em;
    background-color: var(--sidebar-nav-btn-bg);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: var(--sidebar-nav-btn-text);
    transition: all 0.2s;
}

.sidebarNav button:hover {
    background-color: var(--sidebar-header-bg);
    color: var(--sidebar-header-text);
}

/* Sidebar Content */
.sidebarContent {
    flex: 1;
    padding: 1em;
    overflow-y: auto;
}

.sidebarContent section {
    margin-bottom: 1.5em;
}

.sidebarContent h4 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-size: 1.1em;
    color: var(--sidebar-header-bg);
}

.sidebarContent p,
.sidebarContent li,
.sidebarContent ol {
    font-size: 0.95em;
    line-height: 1.5;
    color: var(--text-primary);
}

/* PWA install button */
#btnInstallApp {
    display: inline-block;
    margin-top: 0.8em;
    padding: 0.7em 1.2em;
    background-color: var(--sidebar-header-bg);
    color: var(--text-inverted);
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#btnInstallApp:hover {
    background-color: color-mix(in srgb, var(--sidebar-header-bg) 90%, black 10%);
}

/* Responsive */
@media (max-width: 768px) {
    #sidebarPanel {
        width: 100%;
    }

    .sidebarNav button {
        font-size: 0.9em;
        padding: 0.5em 0.6em;
    }
}

/* ------ Alertas ------ */
#alertContainer {
    position: fixed;
    top: 8.5%;
    width: 100%;
    display: flex;
    gap: 1.2vh;
    z-index: 9999;
    pointer-events: none;
    flex-direction: column;
    align-items: center;
}

.alert-box {
    pointer-events: auto;
    background: var(--alert-warn-bg);
    border-left: 5px solid var(--alert-warn-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    padding: 12px 40px 12px 14px;
    border-radius: 8px;
    position: relative;
    max-width: 360px;
    animation: fadeIn 0.32s ease;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    color: var(--text-secondary);
}

.alert-box .alert-title {
    display: block;
    font-weight: 700;
    margin-bottom: 0.45vh;
    color: var(--text-primary);
    font-size: 1.85vh;
}

.alert-box .alert-body {
    font-size: 13px;
    line-height: 1.25;
    color: var(--text-secondary);
}

.alert-box .close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 4px;
    line-height: 1;
}

.alert-box.info {
    background: var(--alert-info-bg);
    border-left-color: var(--alert-info-border);
}

.alert-box.warn {
    background: var(--alert-warn-bg);
    border-left-color: var(--alert-warn-border);
}

.alert-box.error {
    background: var(--alert-error-bg);
    border-left-color: var(--alert-error-border);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Config overlay and window */
.global-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 10100;
    transition: opacity 0.3s ease-in-out;
}

.global-backdrop.hidden {
    display: none !important;
    opacity: 0;
}

.global-backdrop:not(.hidden) {
    opacity: 1;
}

/* Ventana de configuración */
.config-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    width: 90%;
    max-width: 360px;
    border-radius: 16px;
    box-shadow: 0 0 25px rgba(0,0,0,0.3);
    z-index: 10102;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: config-pop 0.25s ease;
}

/* Animación */
@keyframes config-pop {
    from {
        transform: translate(-50%, -50%) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Encabezado */
.config-header {
    background: var(--bg-primary);
    color: var(--text-inverted);
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    padding: 14px;
}

/* Cuerpo */
.config-body {
    padding: 16px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Secciones */
.config-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-label {
    font-weight: 600;
    color: var(--bg-primary-readeable);
    font-size: 14px;
}

.config-option {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-option.row {
    flex-direction: column;
}

.config-option span {
    font-size: smaller;
}

/* Select */
.config-select {
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 6px;
    background: var(--input-bg);
    color: var(--input-text);
    width: 100%;
}

/* Utils */

.no-border {
    border: unset !important;
}

.no-events {
    pointer-events: none;
}

.no-spacing {
    margin: 0 !important;
    padding: 0 !important;
}

/* Toggle personalizado */
.config-toggle {
    position: relative;
    width: 46px;
    height: 24px;
}

.config-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.config-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #616161;
    border-radius: 24px;
    transition: .3s;
}

.config-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-inverted);
    border-radius: 50%;
    transition: .3s;
}

.config-toggle input:checked + .config-slider {
    background-color: var(--bg-primary);
}

.config-toggle input:checked + .config-slider:before {
    transform: translateX(22px);
}

/* Sidebar redes */
#sidebarRedes ul {
    list-style: none;
    padding: 0;
}

#sidebarRedes ul li {
    margin-bottom: 0.5rem;
}

#sidebarRedes ul li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s;
}

#sidebarRedes ul li a:hover {
    color: color-mix(in srgb, var(--sidebar-header-bg) 85%, black 15%);
}

/* Scrollbars (Webkit) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 8px;
}

/* */







/* ------------------------------------------- */
/* Estilos Generales y Comunes de Popup */
/* ------------------------------------------- */

/* Base del Popup (Usa variables de overlay y sombras) */
.popup-overlay  {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10101;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: visible;
    opacity: 1;
    transition: visibility 0.3s, opacity 0.3s ease;
}

.popup-overlay.hidden {
    visibility: hidden;
    opacity: 0;
    transition-delay: 0s;
}

.popup-container {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--box-shadow-strong);
    width: 90%;
    height: 80%;
    max-width: 500px;
    max-height: 700px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(1);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.popup-overlay.hidden .popup-container {
    transform: scale(0.95);
    opacity: 0;
}

.popup-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    flex-shrink: 0;
    background-color: var(--bg-primary);
    color: var(--text-inverted);
}

.route-icon-color-display {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-inverted);
    background-color: var(--mix-hover);
    margin-right: 15px;
    font-size: 1.3rem;
    box-shadow: var(--box-shadow-soft);
}

.popup-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-inverted);
    margin: 0;
}

.generic-btn {
    margin-top: 10px;
    font-size: 1.1rem;
    background: var(--bg-primary);
    color: var(--text-inverted);
    padding: 1vh;
    opacity: 1;
    border: 0.3vh solid var(--scrollbar-track);
    border-radius: 1vh;
    cursor: pointer;
}

.close-btn {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-inverted);
    transition: opacity 0.2s;
    line-height: 1;
    opacity: 0.8;
    cursor: pointer;
}

.close-btn.btn-interactive {
    margin-left: auto;
    color: var(--text-primary);
    font-size: 0.9rem;
    border: 1px solid var(--input-border);
    border-radius: 1vh;
    padding: 5px 10px;
}

.close-btn:hover {
    opacity: 1;
}

.popup-content-scroll {
    overflow-y: auto;
    padding: 20px;
    flex-grow: 1;
    background-color: var(--background-color);
}

.info-section {
    margin-bottom: 25px;
}

.section-title {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--bg-primary);
}

.bus-display-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
}

.bus-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 15px;
    flex-shrink: 0;
    background-color: var(--scrollbar-track);
}

.bus-text-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bus-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bus-company {
    font-size: 0.95rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--input-border);
}

.info-list .list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--scrollbar-track);
}

.info-list .list-item:last-child {
    border-bottom: none;
}

.stop-icon-wrapper {
    width: 32px;
    height: 32px;
    margin-right: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stop-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.stop-icon-fa {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.list-item .item-name {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* MAP LIBRE */

.maplibregl-popup-content {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--input-border) !important;
    box-shadow: var(--box-shadow-strong) !important;
    border-radius: 8px;
    padding: 0 !important; /* Reseteamos padding para control total */
    font-family: sans-serif;
    max-width: 280px !important;
}

/* Oculta la flecha/ancla para un look más limpio y minimalista */
.maplibregl-popup-tip {
    display: none;
}

/* Botón de cerrar (X) */
.maplibregl-popup-close-button {
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 3px;
    margin: 2px;
    line-height: 1;
}
.maplibregl-popup-close-button:hover {
    color: var(--text-primary);
    background: none;
}

/* --- Clases personalizadas para el contenido HTML inyectado --- */

.map-popup-container {
    padding: 1vh 3vh 1vh 3vh;
    background: var(--bg-secondary);
}

.popup-route-title {
    font-size: small;
    color: var(--text-primary);

    margin: 0 0 10px 0;
    border-bottom: 2px solid var(--bg-primary);
    padding-bottom: 5px;
}

.popup-route-details {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.4;
}
.popup-route-details strong {
    color: var(--text-primary);
}

.popup-route-button {
    background-color: var(--bg-primary);
    color: var(--text-inverted);
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    font-size: small;
    transition: background-color 0.2s;
}
.popup-route-button:hover {
    background-color: var(--mix-hover);
}

/* */


/* --- Estilos del Marcador GPS Personalizado --- */

.gps-marker {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    user-select: none;
}

.gps-marker-dot {
    width: 18px;
    height: 18px;
    background-color: #007aff;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    z-index: 2;
    position: relative; 
    box-sizing: border-box; 
}

.gps-marker::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #007aff;
    opacity: 0.2;
    z-index: 1; 
    animation: pulse 2s infinite ease-out;
}

.gps-heading {
    position: absolute;
    width: 50px;
    height: 60px;
    background: radial-gradient(circle at 50% 0%, rgba(0, 122, 255, 0.6) 0%, transparent 80%);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    z-index: 0;
    top: 12px;
    left: calc(50% - 25px);
    transform-origin: 50% 0%;
    transition: transform 0.2s linear;
}

.gps-marker.grayed-out .gps-marker-dot {
    /* background-color: #999999;
    border-color: #f0f0f0; */
    filter: grayscale(1);
}

.gps-marker.grayed-out::before,
.gps-marker.grayed-out .gps-heading {
    display: none;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.2;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}    
.gps-marker.gps-type-arrow {
    width: 56px; /* Área de rotación amplia para que no se corte la sombra */
    height: 56px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gps-arrow-shape {
    width: 40px; /* Tamaño visual de la flecha */
    height: 40px;
    transform-origin: center center;
    /* Sombra suave y elevada típica de apps de mapas */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
    transition: transform 300ms linear;
    will-change: transform; /* Optimización de rendimiento */
}

.gps-arrow-shape svg {
    width: 100%;
    height: 100%;
    overflow: visible; /* Permite que el borde (stroke) se vea completo */
}

.gps-arrow-shape path {
    fill: #1A73E8; /* Azul Google Maps oficial */
    stroke: #FFFFFF;
    stroke-width: 4px; /* Borde blanco grueso y limpio */
    stroke-linejoin: round; /* Esquinas suavizadas */
    stroke-linecap: round;
    /* Truco CSS: El borde se pinta 'detrás' del relleno para no reducir el tamaño azul */
    paint-order: stroke; 
}

/* Estado Inactivo (Gris) */
.gps-marker.grayed-out.gps-type-arrow .gps-arrow-shape path {
    fill: #9AA0A6; /* Gris Google */
}



/* --- Estilos del Popup Modal --- */

.popup-content-dynamic {
    
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    /* max-width: 400px; */
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 12px;
    box-shadow: var(--box-shadow-strong);
    padding: 24px;
    text-align: center;
    display: none; /* Oculto por defecto, JS lo mostrará */
    /* z-index se aplica vía JavaScript */
}

.popup-content-dynamic h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.popup-content-dynamic p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.popup-content-dynamic .popup-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 16px;
}

.popup-content-dynamic .popup-custom-html {
    margin-bottom: 24px;
    text-align: left;
    color: var(--text-secondary);
}

.popup-button-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.popup-button-dynamic {
    background-color: var(--bg-primary);
    color: var(--text-inverted);
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    width: 100%;
    transition: opacity 0.2s;
}

.popup-button-dynamic:hover {
     opacity: 0.9;
}

.popup-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    z-index: 10; 
}



.popup-close-btn:hover {
    color: var(--text-primary);
}

/* MAP */

.maplibregl-ctrl-group {
    background-color: var(--bg-secondary) !important;
}

.maplibregl-ctrl-group:not(:empty) {
    box-shadow: var(--box-shadow-strong) !important;
}

.maplibregl-ctrl button .maplibregl-ctrl-icon {
    /* background-position: unset !important;  */
    /* background-repeat: unset !important;  */
    /* display: block;
    height: unset !important; 
    width: unset !important;  */
}


.maplibregl-ctrl-icon {
    color: var(--bg-primary-readeable);
    transition: all 0.3s ease;
}

.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon {
    background-image: none !important;
}


.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before {
    content: "\f067"; 
    font-family: "Font Awesome 5 Free";
    font-weight: 900; 
    display: block;
    padding: 1vh 0.9vh 0vh 0.9vh;
    font-size: larger;
    text-align: center;
}

.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
    background-image: none !important;
}

.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before {
    content: "\f068"; 
    font-family: "Font Awesome 5 Free";
    font-weight: 900; 
    display: block;
    padding: 1vh 0.9vh 0vh 0.9vh;
    font-size: larger;
    text-align: center;
}

.maplibregl-ctrl-compass .maplibregl-ctrl-icon {
    background-image: none !important;
}

.maplibregl-ctrl-compass .maplibregl-ctrl-icon::before {
    content: "\f124"; 
    font-family: "Font Awesome 5 Free";
    font-weight: 900; 
    display: block;
    padding: 1vh;
    font-size: larger;
    text-align: center;
    rotate: 315deg;
}

/* CUSTOM ICONS */

.c-icon .fa-location {
    display: inline-block;
}

.c-icon {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    color: var(--bg-primary-readeable);
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* ADS */

.ad-box {
    display: flex;
    margin: auto;
    justify-content: center;
}

.ad-close {
    position: absolute;
    /* top: 14px; */
    /* bottom: auto; */
    right: 10px;
    /* width: 22px; */
    /* height: 22px; */
    border: none;
    border-radius: 50%;
    background: #000000cc;
    color: white;
    font-size: 16px;
    line-height: 20px;
    cursor: pointer;
    z-index: 5;
}

.ad-close:hover {
    background: #000000ee;
}

.auto-ad {
    width: 100%;
    height: 100%;
}

.ad-container {
    cursor: pointer;
}

/* SPECIAL */

@keyframes x_motion {
    from { background-position-x: 0; }
    to { background-position-x: 1000px; }
}

@keyframes light_flash {
    0%, 100% {
        filter: brightness(100%) drop-shadow(0 0 0 transparent);
    }
    50% {
        filter: brightness(380%) drop-shadow(0 5px 15px rgba(255, 215, 0, 0.8));
    }
}

.special_lights_bg {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    background-image: url(../img/special/top_christmas_lights.png);
    background-repeat: repeat-x;
    background-size: contain;
    pointer-events: none;
    z-index: -1;
    animation: x_motion 95s linear infinite, light_flash 1s ease-in-out infinite alternate;
}

.special_lights_bg_bottom {
    position: absolute; 
    left: 0; 
    width: 100%;  
    height: 100%; 
    background-image: url(../img/special/bottom_christmas.png);
    background-repeat: repeat-x;
    pointer-events: none;
    opacity: 75%;
    background-size: contain;
    z-index: -1;
    animation: x_motion 360s linear infinite;
}