html {
    overflow: hidden !important;
}

body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

.mapa-container {
    display: flex;
    flex-direction: column;
    height: 94vh;
    width: 100%;
    position: relative;
}

footer.mkdf-page-footer {
    position: relative !important;
    z-index: 100 !important;
    width: 100%;
    margin-top: 0;
}

h2 {
    font-size: 35px !important;
}

/* Filtres */
.mapa-capcalera {
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}
.capcalera-toggle {
    padding: 6px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.capcalera-toggle:hover {
    background: #e9ecef;
}
.capcalera-toggle h3 {
    margin: 0;
    font-size: 14px;
    color: #2c3e50;
}
.capcalera-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 20px;
}
.capcalera-content.open {
    max-height: 200px;
    padding: 0 20px 10px;
}
.mapa-capcalera p {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: #555;
}

.filtres-container {
    background: white;
    border-bottom: 1px solid #ddd;
    position: relative;
    z-index: 100;
}

.filtres-toggle {
    padding: 6px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.filtres-toggle:hover {
    background: #e9ecef;
}

.filtres-toggle h3 {
    margin: 0;
    font-size: 14px;
    color: #2c3e50;
}

.filtres-toggle-icon {
    transition: transform 0.3s;
}

.filtres-toggle-icon.open {
    transform: rotate(180deg);
}

.filtres-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.filtres-content.open {
    max-height: 250px;
    overflow: visible;
}

.cerca-nom-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}
.cerca-nom-item:hover {
    background-color: #e9f5e9;
}
.cerca-nom-item:last-child {
    border-bottom: none;
}

.filtres-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 12px;
    padding: 10px 15px;
    background: white;
}

.filtre-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filtre-group label {
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
}

.filtre-group select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.filtre-group select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.filtre-group select:disabled {
    background: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Multi-select personalitzat */
.multi-select-container {
    position: relative;
}

.multi-select-display {
    padding: 5px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 30px;
    transition: border-color 0.2s;
}

.multi-select-display:hover {
    border-color: #80bdff;
}

.multi-select-display.active {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.multi-select-display .selected-text {
    flex: 1;
    font-size: 13px;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multi-select-display .dropdown-arrow {
    margin-left: 8px;
    font-size: 12px;
    color: #6c757d;
    transition: transform 0.3s;
}

.multi-select-display.active .dropdown-arrow {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.multi-select-dropdown.open {
    max-height: 280px;
    overflow-y: auto;
    opacity: 1;
}

.checkbox-option {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.checkbox-option:hover {
    background: #f8f9fa;
}

.checkbox-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-option input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.checkbox-option span {
    font-size: 14px;
    color: #495057;
}

.checkbox-option input[type="checkbox"]:disabled + span {
    color: #adb5bd;
}

.multi-select-container.disabled .multi-select-display {
    background: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

.multi-select-container.disabled .multi-select-display:hover {
    border-color: #ced4da;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-values {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6c757d;
}

.range-slider {
    position: relative;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
}

.range-slider input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    background: transparent;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: all;
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.range-slider input[type="range"]::-moz-range-thumb {
    pointer-events: all;
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.filtres-actions {
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #e9ecef;
}

.btn-filtres {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-aplicar {
    background: #007bff;
    color: white;
}

.btn-aplicar:hover {
    background: #0056b3;
}

.btn-netejar {
    background: #6c757d;
    color: white;
}

.btn-netejar:hover {
    background: #545b62;
}

/* Container mapa + info */
.mapa-info-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.mapa-columna {
    width: 60%;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

.info-columna {
    width: 40%;
    height: 100%;
    overflow: hidden;
    background: #f8f9fa;
    border-left: 1px solid #ddd;
}

.rutes-llistat {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

.ruta-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ruta-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.ruta-card h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 18px;
}

.ruta-stats {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    font-size: 14px;
    color: #666;
}

.ruta-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ruta-detall {
    display: none;
    padding: 15px 20px 20px 20px;
    background: white;
    height: 100%;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

.ruta-detall.active {
    display: block;
}

.detall-tornar {
    margin-bottom: 10px;
}

.detall-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e9ecef;
    gap: 10px;
}

.detall-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 18px;
    flex: 0 0 60%;
    min-width: 0;
}

.detall-header #detall-categories {
    text-align: right;
    flex: 0 0 38%;
    min-width: 0;
    font-size: 16px;
}

.btn-tornar {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-tornar:hover {
    background: #5a6268;
}

.detall-stats {
    display: grid;
    gap: 10px;
    margin: 10px 0;
}
.detall-stats-3 {
    grid-template-columns: repeat(3, 1fr);
}
.detall-stats-2 {
    grid-template-columns: repeat(2, 1fr);
}

.stat-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
}

.stat-box .label {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-box .value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
}

.detall-descripcio {
    margin: 20px 0;
    line-height: 1.6;
    color: #495057;
}

#elevation-div {
    width: 100%;
    height: 260px;
    margin: 20px 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.detall-section {
    margin: 20px 0;
}

.detall-section h3 {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 5px;
}

.foto-ruta-container {
    margin-top: 15px;
    text-align: center;
}

.foto-ruta-container img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.foto-ruta-container img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* Modal para ver foto en grande */
.foto-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
}

.foto-modal.active {
    display: flex;
}

.foto-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.foto-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.foto-modal-close:hover {
    color: #bbb;
}

.dificultat {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.dificultat-1 { 
    background: #d4edda; 
    color: #155724; 
}

.dificultat-2 { 
    background: #fff3cd; 
    color: #856404; 
}

.dificultat-3 { 
    background: #f8d7da; 
    color: #721c24; 
}

.ol-control > * {
    background-color: #f8f8f8!important;
    color: #444444!important;
    border-radius: 0px;
}

.ol-control {
    background-color: rgba(255,255,255,.4) !important;
    padding: 2px !important;
}

.ol-popup {
    display: none !important;
}

.ol-popup-closer {
    display: none;
}

#popup {
    display: none !important;
}

#ol-search-input {
    width: 250px !important;
}

/* Botons de descàrrega GPX */
.btn-descarregar-gpx {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s;
}

.btn-descarregar-gpx:hover {
    background: #218838;
    color: white;
}
a.btn-descarregar-gpx,
a.btn-descarregar-gpx:hover,
a.btn-descarregar-gpx:visited,
a.btn-descarregar-gpx:active {
    color: white;
}

.btn-descarregar-gpx:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-descarregar-zip {
    position: relative;
    float: right;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Diàleg d'ubicació */
.ubicacio-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ubicacio-dialog {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ubicacio-dialog h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ubicacio-dialog p {
    margin: 0 0 25px 0;
    color: #666;
    line-height: 1.6;
    font-size: 15px;
}

.ubicacio-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-ubicacio {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn-ubicacio-si {
    background: #007bff;
    color: white;
}

.btn-ubicacio-si:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.btn-ubicacio-no {
    background: #e9ecef;
    color: #495057;
}

.btn-ubicacio-no:hover {
    background: #d3d6d9;
}

/* Marcador d'ubicació de l'usuari - Pin estil Google Maps */
.user-location-marker {
    width: 36px;
    height: 36px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z" fill="%23EA4335"/><circle cx="12" cy="9" r="2.5" fill="%23B31412"/><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z" fill="none" stroke="white" stroke-width="0.8"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
    animation: bouncePin 2s infinite;
    transform: translate(-50%, -100%);
}

@keyframes bouncePin {
    0%, 100% {
        transform: translate(-50%, -100%);
    }
    50% {
        transform: translate(-50%, calc(-100% - 4px));
    }
}

/* Botó de geolocalització als controls del mapa */
.geolocation-control {
    position: relative !important;
    background-color: rgba(255,255,255,.4) !important;
    padding: 2px !important;
    padding-top: 10px !important;
    margin-left: 8px !important;
}

.geolocation-control button {
    background-color: #f8f8f8 !important;
    color: #444444 !important;
    border: none;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s;
    position: relative;
}

.geolocation-control button:hover {
    background-color: #e0e0e0 !important;
}

.geolocation-control button.active {
    color: #007bff !important;
}

/* Icona de pin estil Google Maps */
.geolocation-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23444444"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.geolocation-control button.active .geolocation-icon {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23007bff"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/></svg>');
}

/* Tooltips personalitzats per als controls del mapa */
.map-tooltip {
    position: absolute;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.map-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 6px 6px 0;
    border-color: transparent rgba(44, 62, 80, 0.95) transparent transparent;
}

.map-tooltip.visible {
    opacity: 1;
}

#top-left-container .ol-control button {
    position: relative;
}

/* Millores pel perfil d'elevació */
#elevation-div {
    width: 100%;
    height: 350px;
    margin: 20px 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    position: relative;
    overflow: visible;
}

#elevation-div svg {
    border-radius: 6px;
}

#elevation-div .grid line {
    stroke: #e9ecef;
    stroke-opacity: 0.7;
}

#elevation-div .grid path {
    stroke-width: 0;
}

#elevation-div .elevation-polyline {
    stroke: #007bff;
    stroke-width: 3px;
    fill: none;
}

#elevation-div .area {
    fill: rgba(0, 123, 255, 0.15);
}

#elevation-div .height-focus.line {
    stroke: #e74c3c;
    stroke-width: 2px;
}

#elevation-div .height-focus.circle {
    fill: #e74c3c;
    stroke: white;
    stroke-width: 2px;
}

#elevation-div .axis text {
    font-size: 11px;
    fill: #666;
}

#elevation-div .axis path,
#elevation-div .axis line {
    stroke: #999;
    stroke-width: 1px;
}

#elevation-div .tick text {
    font-weight: 500;
}

.elevation-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 13px;
    border: 1px solid #dee2e6;
}
.elevation-info strong {
    color: #2c3e50;
    display: block;    
}

.elevation-info small {
    color: #6c757d;
}

/* Ocultar creu de tancar del perfil d'elevació */
#elevation-div .leaflet-control-elevation .close-button,
#elevation-div .leaflet-control-elevation a.close,
#elevation-div .close-button,
.elevation-close,
.leaflet-control-elevation-toggle,
#elevation-div .leaflet-control-elevation > a,
.elevation-toggle-icon {
    display: none !important;
}

/* Ocultar enllaços de QGIS/qgis2web/OpenLayers */
.ol-attribution,
.ol-attribution ul,
.ol-attribution li,
a[href*="qgis"],
a[href*="openlayers"],
a[href*="qgis2web"] {
    display: none !important;
}

/* Ocultar control d'atribució completament */
.ol-control.ol-attribution {
    display: none !important;
}


.btn-expandir-detall {
    display: none;
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1002;
    background: #007bff;
    backdrop-filter: blur(5px);
    color: #fff;
    border: none;
    border-bottom: 1px solid #0069d9;
    padding: 8px 0;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    font-size: 13px;
    font-weight: 600;
    border-radius: 0 0 6px 6px;
}

.btn-expandir-detall:hover {
    background: #0056b3;
    color: #fff;
}

.btn-expandir-detall:active {
    background: #004494;
}

.btn-expandir-detall svg {
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease;
    vertical-align: middle;
    fill: #fff;
}

.btn-expandir-detall.expandit svg {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .mapa-info-container {
        flex-direction: column;
    }
    
    .mapa-columna {
        width: 100%;
        height: 50vh;
    }
    
    .info-columna {
        width: 100%;
        height: 50vh;
        transition: all 0.3s ease;
        overflow: hidden; /* CANVIAT: evitar scroll addicional */
    }

    /* Quan el detall està expandit */
    .info-columna.expandit {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 80vh;
        z-index: 1000;
        background: white;
    }

    .ruta-detall {
        height: 100%;
        overflow-y: auto; /* Scroll només aquí */
    }

    .ruta-detall.expandit {
        height: 100%;
    }

    .rutes-llistat {
        height: 100%;
        overflow-y: auto; /* Scroll només aquí */
    }
    
    .filtres-grid {
        grid-template-columns: 1fr;
    }

    /* Millorar visualització dels filtres en mobile */
    .filtres-content {
        background: white;
        position: relative;
        z-index: 101;
    }

    .filtres-content.open {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }

    .btn-descarregar-zip {
        float: none !important;
    }

    .btn-expandir-detall {
        display: block;
    }

    /* Tancar search layer amb click fora */
    .search-layer-input-search {
        max-width: calc(100vw - 80px) !important;
    }
}