/* ===== RESET I ESTILS BÀSICS ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    background-color: #f5f5f5;
    color: #333;
    touch-action: pan-x pan-y;
}

/* ===== PANTALLA D'INICI ===== */
.pantalla-inicio {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.contenedor-inicio {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.contenedor-inicio h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 30px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== SELECCIÓ D'IDIOMA ===== */
.seleccion-idioma {
    margin-bottom: 30px;
}

.seleccion-idioma h2 {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 20px;
    font-weight: 500;
}

.botones-idioma {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.boton-idioma {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 12px 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 50px;
}

.boton-idioma:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.boton-idioma.activo {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* ===== AVÍS DE GEOLOCALITZACIÓ ===== */
.aviso-geocalizacion {
    background: #e3f2fd;
    border: 2px solid #2196f3;
    border-radius: 15px;
    padding: 25px;
    margin-top: 20px;
}

.aviso-geocalizacion p {
    color: #0d47a1;
    font-size: 1.1rem;
    margin-bottom: 20px;
    font-weight: 500;
    text-align: center;
}

.botones-aviso {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.botones-aviso button {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

#btn-continuar {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
}

#btn-continuar:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
}

#btn-salir {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e0e0e0;
}

#btn-salir:hover {
    background: white;
    border-color: #666;
    color: #333;
}

/* ===== PANTALLA DE L'APP ===== */
.pantalla-app {
    display: none;
    flex-direction: column;
    height: 100vh;
    background: white;
}

.pantalla-app.activa {
    display: flex;
}

.oculto {
    display: none !important;
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: 700;
    text-align: center;
}

.controles-rango {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.controles-rango label {
    font-size: 0.9rem;
    font-weight: 500;
}

#valor-rango {
    font-weight: 700;
    color: #ffeb3b;
}

#rango-distancia {
    width: 100%;
    max-width: 300px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    -webkit-appearance: none;
}

#rango-distancia::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffeb3b;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#rango-distancia::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffeb3b;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ===== MAPA ===== */
#mapa {
    flex: 1;
    width: 100%;
    position: relative;
}

/* Estils per al mapa de Leaflet */
.leaflet-container {
    background: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.leaflet-popup-content {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* ===== CONTROLS DE L'APP ===== */
.controles-app {
    background: white;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
}

.controles-principales {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.boton-control {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.boton-control:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.boton-control:active {
    transform: translateY(-1px) scale(1.02);
}

.boton-control.activo {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

/* ===== SELECTOR DE TIPUS ===== */
.selector-tipo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.selector-tipo label {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

#tipo-narracion {
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    font-size: 0.9rem;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

#tipo-narracion:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#tipo-narracion:hover {
    border-color: #667eea;
}

/* ===== PANELL DE TEXTE ===== */
.panel-texto {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.panel-texto.activo {
    opacity: 1;
    visibility: visible;
}

.panel-contenido {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.panel-texto.activo .panel-contenido {
    transform: translateY(0);
}

.boton-cerrar {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.boton-cerrar:hover {
    background: #f5f5f5;
    color: #333;
}

#titulo-narracion {
    color: #333;
    font-size: 1.8rem;
    margin-bottom: 20px;
    font-weight: 700;
    padding-right: 50px;
}

#contenido-narracion {
    color: #555;
    line-height: 1.6;
    font-size: 1.1rem;
    margin-bottom: 25px;
}

#contenido-narracion p {
    margin-bottom: 15px;
}

.fuente {
    color: #888;
    font-size: 0.9rem;
    font-style: italic;
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    margin-top: 20px;
}

/* ===== INDICADORS DEL MAPA ===== */
.marcador-usuario {
    background: none !important;
    border: none !important;
}

.marcador-usuario .icono {
    width: 20px;
    height: 20px;
    background: #4285f4;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.marcador-poi {
    background: none !important;
    border: none !important;
}

.marcador-poi .icono {
    width: 30px;
    height: 30px;
    background: #ff6b6b;
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 3px 15px rgba(255, 107, 107, 0.4);
}

.circulo-exploracion {
    stroke: #4285f4;
    stroke-width: 2;
    fill: rgba(66, 133, 244, 0.1);
    fill-rule: evenodd;
}

/* ===== ANIMACIONS ===== */
@keyframes latido {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.latido {
    animation: latido 2s infinite;
}

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

.animacion-aparecer {
    animation: aparecer 0.5s ease-out;
}

/* ===== ESTATS DE CARREGA ===== */
.estado-cargando {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== AVÍS DE CONNEXIÓ ===== */
.aviso-conexion {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff6b6b;
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.3);
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.aviso-conexion.activo {
    display: flex;
    animation: aparecer 0.3s ease-out;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .contenedor-inicio {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .contenedor-inicio h1 {
        font-size: 2rem;
    }
    
    .botones-idioma {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .boton-idioma {
        font-size: 0.85rem;
        min-height: 45px;
    }
    
    .botones-aviso {
        flex-direction: column;
    }
    
    .botones-aviso button {
        min-width: auto;
    }
    
    header {
        padding: 12px 15px;
    }
    
    header h1 {
        font-size: 1.3rem;
    }
    
    .controles-rango label {
        font-size: 0.85rem;
    }
    
    .controles-principales {
        gap: 15px;
    }
    
    .boton-control {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }
    
    .selector-tipo {
        flex-direction: column;
        gap: 8px;
    }
    
    #tipo-narracion {
        min-width: 100%;
    }
    
    .panel-contenido {
        padding: 25px 20px;
        margin: 15px;
    }
    
    #titulo-narracion {
        font-size: 1.5rem;
    }
    
    #contenido-narracion {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .pantalla-inicio {
        padding: 15px;
    }
    
    .contenedor-inicio {
        padding: 25px 15px;
        margin: 10px;
    }
    
    .contenedor-inicio h1 {
        font-size: 1.8rem;
    }
    
    .botones-idioma {
        grid-template-columns: 1fr;
    }
    
    .aviso-geocalizacion {
        padding: 20px 15px;
    }
    
    .aviso-geocalizacion p {
        font-size: 1rem;
    }
    
    .controles-app {
        padding: 15px;
    }
    
    .controles-principales {
        gap: 10px;
    }
    
    .boton-control {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .panel-contenido {
        padding: 20px 15px;
    }
    
    #titulo-narracion {
        font-size: 1.3rem;
    }
}

/* ===== MODE FOSC (OPCIONAL) ===== */
@media (prefers-color-scheme: dark) {
    .pantalla-inicio {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .contenedor-inicio {
        background: #2c3e50;
        color: white;
    }
    
    .contenedor-inicio h1 {
        color: white;
        background: linear-gradient(135deg, #3498db 0%, #9b59b6 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }
    
    .seleccion-idioma h2 {
        color: #bdc3c7;
    }
    
    .boton-idioma {
        background: #34495e;
        border-color: #4a5f7a;
        color: #ecf0f1;
    }
    
    .aviso-geocalizacion {
        background: #1a252f;
        border-color: #3498db;
    }
    
    .aviso-geocalizacion p {
        color: #3498db;
    }
    
    #btn-salir {
        background: #34495e;
        color: #bdc3c7;
        border-color: #4a5f7a;
    }
}

/* ===== UTILITATS ===== */
.texto-centrado {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.sombra-suave {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.borde-redondeado {
    border-radius: 15px;
}

/* ===== SCROLLBAR PERSONALITZAT ===== */
.panel-contenido::-webkit-scrollbar {
    width: 8px;
}

.panel-contenido::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.panel-contenido::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.panel-contenido::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== ACCESSIBILITAT ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible per a accessibilitat */
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Millores per a lectors de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}