body { margin: 0; font-family: system-ui, sans-serif; overflow: hidden; }
#map { width: 100vw; height: 100vh; }

/* Sidebar Buttons */
.sidebar-btn {
    position: absolute; right: 10px; width: 30px; height: 30px;
    background: #fff; border: 1px solid #ccc; border-radius: 4px;
    cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    display: flex; align-items: center; justify-content: center;
    z-index: 5; font-size: 16px; color: #333;
}
.sidebar-btn:hover { background: #f2f2f2; }
#layers-btn { top: 110px; }
#tool-btn { top: 150px; }

/* Panels */
.controls, #tool-panel {
    position: absolute; right: 50px; background: rgba(255, 255, 255, 0.95);
    border-radius: 8px; padding: 10px 14px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    z-index: 4; font-size: 14px; min-width: 220px; max-height: 80vh;
    overflow-y: auto; display: none;
}
.controls { top: 110px; }
#tool-panel { top: 150px;  }
.controls h3 { margin: 5px 0; font-size: 15px; }

label { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; cursor: pointer; }
.legend-icon {
    width: 14px; height: 20px; display: inline-block; background: currentColor;
    border-radius: 0 0 50% 50%;
    clip-path: polygon(50% 0%, 100% 25%, 100% 100%, 0% 100%, 0% 25%);
}
/* Tables */
.popup-table, #realtimedata { 
border-collapse: collapse; 
width: 100%; 
max-width: 220px; /* Limita l'amplada màxima perquè quedi petita */
font-size: 14px; /* Lletra més petita */
font-family: sans-serif;
}

#realtimedata td { 
border-top: 1px solid #ddd; 
padding: 3px 5px; /* Padding reduït per fer-ho compacte */
}

/* Primera columna (títols) */
#realtimedata td:first-child { 
font-weight: bold; 
color: black; 
text-align: left;
white-space: nowrap;
}

/* Segona columna (valors i unitats) */
#realtimedata .right_td { 
text-align: right;  
white-space: nowrap; 
}

/* Fila de separació per les categories (METEO, TSS) */
#realtimedata .section-header td {
background: #f9f9f9; 
text-align: center; 
font-weight: bold;
border-top: 1px solid #ddd;
}

/* Estils extres que ja tenies pel popup */
.maplibregl-popup-content { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.maplibregl-popup-tip { border-top-color: rgba(255, 255, 255, 0.8) !important; }
/* Action Bar */
.action-bar { 
display: flex; 
align-items: center; 
gap: 12px; /* Separació entre la columna de botons i el desplegable */
margin-bottom: 12px; 
background: #f8f9fa; 
padding: 4px 4px 4px 4px; 
border-radius: 4px; 
border: 1px solid #ddd; 
}

/* Nou contenidor per apilar el zoom i el follow */
.controls-col {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px; /* Separació vertical entre el botó i el text de Follow */
}

/* Estils de l'etiqueta Follow */
.follow-label {
font-size: 9px; 
margin: 0;
cursor: pointer;
color: #444;
}

#vessel-selector { 

padding: 4px; 
border-radius: 4px; 
border: 1px solid #ccc; 
font-size: 13px;
}

.btn-action { 
cursor: pointer; 
border: 1px solid #ccc; 
background: #fff; 
padding: 3px 5px; 
border-radius: 3px; 
}

.btn-action:hover { 
background: #e9ecef; 
}
/* Iframe Lateral */
#lateral { position: fixed; top: 0; left: -500px; width: 500px; height: 100%; background: #f1f1f1; transition: left 0.3s ease; z-index: 9998; }
#iframe { width: 100%; height: 100%; border: none; }
#cerrar { position: absolute; top: 10px; right: 10px; cursor: pointer; width: 20px; height: 20px; z-index: 10; }
#cerrar::before, #cerrar::after { content: ''; position: absolute; top: 50%; left: 50%; width: 16px; height: 2px; background: #000; transform: translate(-50%, -50%) rotate(45deg); }
#cerrar::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* --- TUTORIAL MODAL STYLES --- */
#tutorial-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6); z-index: 10000;
    display: flex; justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
#tutorial-overlay.active { opacity: 1; pointer-events: all; }

#tutorial-box {
    background: white; width: 90%; max-width: 500px;
    padding: 25px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    font-family: system-ui, sans-serif;
    position: relative;
}

/* NOU: Capçalera del tutorial (Títol + Logo alineats) */
.tutorial-header {
    display: flex;
    justify-content: space-between; /* Títol esquerra, Logo dreta */
    align-items: center;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.tutorial-header h2 {
    margin: 0;
    color: #333;
    font-size: 22px;
}

.tutorial-header-logo img {
    height: 40px; /* Alçada del logo dins del tutorial */
    display: block;
}

.tutorial-step {
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    text-align: left;
}

.tutorial-icon {
    background: #eef4ff;
    color: #3388FF;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.tutorial-content h4 {
    margin: 0 0 5px;
    font-size: 16px;
    color: #444;
}

.tutorial-content p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.tutorial-btn {
    background: #3388FF;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: 15px;
    font-weight: bold;
    transition: background 0.2s;
}

.tutorial-btn:hover {
    background: #256bcf;
}

/* --- LOGO FLOTANT MAPA --- */
#map-logo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

/* --- LOGO FLOTANT MAPA --- */
#map-logo:hover {
    transform: scale(1.05);
}

#map-logo img {
    height: 30px;
    /* Alçada del logo sobre el mapa */
    display: block;
}
#coordinates {position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.9);
    font-family: monospace;
    font-size: 13px;
    font-weight: bold;
    border-radius: 4px;
    z-index: 100;
    pointer-events: none;
    border: 1px sòlid #ccc;
    color: #333;
}
/* Forzar que la atribución (la 'i') esté siempre cerrada */
.maplibregl-ctrl-attrib:not(:hover) .maplibregl-ctrl-attrib-inner {
display: none !important;
}

/* Asegurar que el botón de la "i" se vea siempre */
.maplibregl-ctrl-attrib-button {
display: block !important;
}

/* Quitar el fondo blanco estirado cuando está cerrada */
.maplibregl-ctrl-attrib:not(:hover) {
background: transparent !important;
padding: 0 !important;
}