/* ===================================
   Visor Leaflet - Com fer front a la calor
   Tema basat en #5E86A3
   =================================== */

/* --- Variables de color --- */
:root {
    --primary: #4A7FB5;
    --primary-dark: #3A6A9B;
    --primary-darker: #2D5580;
    --primary-light: #7AAAD4;
    --primary-lighter: #B3CEE5;
    --bg-sidebar: #FFFFFF;
    --bg-sidebar-hover: #F0F5FA;
    --text-dark: #2C3E50;
    --text-medium: #546E7A;
    --text-light: #90A4AE;
    --border-color: #E0E8EF;
    --white: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.1);

    --header-height: 50px;
    --sidebar-width: 370px;
}

/* --- Reset bàsic --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--text-dark);
    overflow: hidden;
}

/* --- Capçalera --- */
#header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--white);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-bottom: 2px solid var(--primary);
}

.header-title {
    flex: 1;
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--primary-dark);
}

.header-badge {
    display: inline-block;
    background: #0f766e;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
    text-transform: lowercase;
    line-height: 1.5;
}

.header-logo {
    height: 32px;
    width: auto;
}

/* Logo AMB a la part esquerra de la capçalera */
.header-logo-amb {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    height: 36px;
    width: auto;
}

/* --- Contenidor principal --- */
#main-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
}

/* --- Sidebar --- */
#sidebar {
    position: relative;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease, min-width 0.3s ease, width 0.3s ease;
    z-index: 500;
    box-shadow: 1px 0 4px rgba(0, 0, 0, 0.05);
}

#sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
    min-width: 0;
    width: 0;
}

#sidebar-toggle {
    position: fixed;
    bottom: 12px;
    left: calc(var(--sidebar-width) - 20px);
    width: 20px;
    height: 48px;
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 2px 1px 4px rgba(0, 0, 0, 0.08);
    transition: background 0.2s, left 0.3s ease, color 0.2s;
    font-size: 11px;
}

#sidebar-toggle:hover {
    background: var(--primary);
    color: var(--white);
}

#sidebar.collapsed #sidebar-toggle {
    left: 0;
}

#sidebar.collapsed #sidebar-toggle i {
    transform: rotate(180deg);
}

/* --- Pestanyes del sidebar --- */
#sidebar-tabs {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    padding: 10px 12px;
    background: var(--white);
    color: var(--text-light);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.sidebar-tab:hover {
    color: var(--primary);
    background: var(--bg-sidebar-hover);
}

.sidebar-tab.active {
    color: var(--primary-dark);
    background: var(--white);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.sidebar-tab i {
    font-size: 14px;
}

/* --- Panels del sidebar --- */
.sidebar-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.sidebar-panel.active {
    display: block;
}

#sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

#sidebar-content::-webkit-scrollbar {
    width: 6px;
}

#sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar-content::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}

/* --- Arbre de capes --- */

/* Apartat principal (nivell 1) */
.tree-section {
    margin-bottom: 2px;
}

.tree-section-header {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    background: #F0F5FA;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    user-select: none;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
}

.tree-section-header:hover {
    background: #E4EDF5;
}

.tree-section-header .toggle-icon {
    margin-right: 8px;
    font-size: 10px;
    transition: transform 0.2s;
    width: 12px;
    text-align: center;
}

.tree-section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.tree-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 0;
}

/* Subapartat (nivell 2) */
.tree-subsection {
    border-bottom: 1px solid var(--border-color);
}

.tree-subsection-header {
    display: flex;
    align-items: center;
    padding: 8px 14px 8px 24px;
    cursor: pointer;
    background: var(--white);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 12.5px;
    user-select: none;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.tree-subsection-header:hover {
    background: var(--bg-sidebar-hover);
}

.tree-subsection-header .toggle-icon {
    margin-right: 8px;
    font-size: 9px;
    transition: transform 0.2s;
    width: 10px;
    text-align: center;
}

.tree-subsection-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.tree-subsection-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 0;
}

/* Comptador de capes actives dins d'un grup */
.layer-count-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--primary);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    line-height: 1;
}
.layer-count-badge[data-count="0"] {
    display: none;
}

/* Subseccions niades (nivell 3+) */
.tree-subsection .tree-subsection-header {
    padding-left: 34px;
    background: #F9FAFB;
    font-size: 12px;
}

.tree-subsection .tree-subsection .tree-subsection-header {
    padding-left: 44px;
    background: #FCFCFD;
    font-size: 11.5px;
}

.tree-subsection .tree-subsection .tree-subsection .tree-subsection-header {
    padding-left: 54px;
    background: #FEFEFE;
    font-size: 11px;
}

/* Capes dins de subseccions niades */
.tree-subsection .tree-layer {
    padding-left: 0;
}

.tree-subsection .tree-subsection .tree-layer {
    padding-left: 0;
}

.tree-subsection .tree-subsection .tree-subsection .tree-layer {
    padding-left: 0;
}

.tree-subsection .tree-layer-header {
    padding-left: 44px;
}

.tree-subsection .tree-subsection .tree-layer-header {
    padding-left: 54px;
}

.tree-subsection .tree-subsection .tree-subsection .tree-layer-header {
    padding-left: 54px;
}

/* Capes (nivell 3) */
.tree-layer {
    display: flex;
    flex-direction: column;
    padding: 6px 14px 6px 34px;
    transition: background 0.2s;
    border-bottom: 1px solid #EEF1F5;
}

.tree-layer:hover {
    background: var(--bg-sidebar-hover);
}

.tree-layer-header {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.tree-layer input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-light);
    border-radius: 3px;
    margin-right: 8px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.tree-layer input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.tree-layer input[type="checkbox"]:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    color: var(--white);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tree-layer label {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dark);
    line-height: 1.3;
    flex: 1;
}

.tree-layer-opacity-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    margin-left: 4px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.tree-layer-opacity-btn:hover {
    color: var(--text-medium);
}

.tree-layer-opacity-btn.active {
    color: var(--primary);
}

/* Botó d'informació de capa */
.tree-layer-info-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    margin-left: 4px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.tree-layer-info-btn:hover {
    color: var(--text-medium);
}

.tree-layer-opacity-control {
    display: none;
    padding: 8px 0 4px 24px;
    align-items: center;
    gap: 8px;
}

.tree-layer-opacity-control.visible {
    display: flex;
}

.opacity-label {
    font-size: 11px;
    color: var(--text-medium);
    white-space: nowrap;
}

.opacity-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.opacity-slider::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

.opacity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.opacity-slider::-moz-range-thumb:hover {
    background: var(--primary-dark);
}

.opacity-value {
    font-size: 11px;
    color: var(--text-dark);
    font-weight: 600;
    min-width: 30px;
    text-align: right;
}

.tree-layer.active {
    background: #EDF4FA;
}

.tree-layer.active label {
    color: var(--primary-dark);
    font-weight: 500;
}

/* --- Mapa --- */
#map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* --- Avís inferior del mapa --- */
#map-disclaimer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    background: rgba(255, 255, 255, 0.82);
    color: #555;
    font-size: 10px;
    line-height: 1.4;
    padding: 3px 10px;
    text-align: center;
    max-width: 700px;
    pointer-events: none;
    white-space: normal;
}

/* --- Panell de capes del cercador --- */
#geocoder-layers-panel {
    position: absolute;
    bottom: 30px;
    left: 20px;
    width: 285px;
    max-height: 420px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 600;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#geocoder-layers-panel.hidden {
    display: none;
}

.gcl-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    color: var(--primary-dark);
    background: #F0F5FA;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.gcl-content {
    overflow-y: auto;
    padding: 6px 0 8px;
}

.gcl-group {
    padding-bottom: 6px;
}

.gcl-group + .gcl-group {
    border-top: 1px solid var(--border-color);
    padding-top: 6px;
}

.gcl-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-dark);
    padding: 4px 14px 5px;
    letter-spacing: 0.6px;
}

.gcl-layer {
    padding: 3px 14px 5px;
}

.gcl-layer-row {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

.gcl-layer-row input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.gcl-layer-row label {
    font-size: 12px;
    color: var(--text-dark);
    cursor: pointer;
    line-height: 1.35;
    flex: 1;
}

.gcl-opacity-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.gcl-opacity-btn:hover {
    color: var(--text-medium);
}

.gcl-opacity-btn.active {
    color: var(--primary);
}

.gcl-opacity-row {
    display: none;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding-left: 19px;
}

.gcl-opacity-row.visible {
    display: flex;
}


/* --- Panell de llegenda --- */
#legend-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 2px 12px var(--shadow);
    z-index: 800;
    max-width: 340px;
    max-height: 480px;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#legend-panel.visible {
    display: block;
}

#legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #F0F5FA;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}

#legend-toggle {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    transition: transform 0.2s;
}

#legend-panel.minimized #legend-toggle i {
    transform: rotate(180deg);
}

#legend-content {
    padding: 10px 12px;
    overflow-y: auto;
    max-height: 420px;
}

#legend-panel.minimized #legend-content {
    display: none;
}

#legend-content::-webkit-scrollbar {
    width: 5px;
}

#legend-content::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}

/* Entrada de llegenda per capa */
.legend-layer {
    margin-bottom: 10px;
}

.legend-layer:last-child {
    margin-bottom: 0;
}

.legend-layer-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--primary-dark);
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--border-color);
}

.legend-layer-subtitle {
    font-weight: 500;
    font-size: 11px;
    color: #666;
    margin-bottom: 3px;
    font-style: italic;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 2px 0;
    font-size: 11.5px;
    color: var(--text-medium);
}

.legend-item img {
    margin-right: 6px;
    flex-shrink: 0;
}

.legend-swatch {
    display: inline-block;
    width: 20px;
    height: 14px;
    margin-right: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.legend-swatch-img {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    flex-shrink: 0;
    object-fit: contain;
}

.legend-swatch-circle {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid;
}

.legend-label {
    flex: 1;
}

/* Elements de llegenda amb filtre */
.legend-item-filterable {
    cursor: pointer;
    transition: background 0.2s;
}

.legend-item-filterable:hover {
    background: rgba(74, 127, 181, 0.1);
}

/* Checkbox de filtre a la llegenda */
.legend-filter-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--primary-light);
    border-radius: 2px;
    margin-right: 6px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
    background: white;
}

.legend-filter-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.legend-filter-checkbox:checked::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 8px;
    color: var(--white);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.legend-filter-checkbox:hover {
    border-color: var(--primary);
}

/* --- Control de mapes base --- */
#basemap-control {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 1000;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
}

#basemap-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--white);
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
    transition: background 0.2s;
}

#basemap-toggle:hover {
    background: var(--bg-sidebar-hover);
}

#basemap-toggle i {
    color: var(--primary);
    font-size: 16px;
}

#basemap-options {
    display: none;
    border-top: 1px solid var(--border-color);
    padding: 10px;
    min-width: 280px;
}

#basemap-options.visible {
    display: block;
}

.basemap-option {
    margin-bottom: 12px;
}

.basemap-option:last-child {
    margin-bottom: 0;
}

.basemap-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.basemap-radio {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-light);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.basemap-radio:checked {
    border-color: var(--primary);
}

.basemap-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.basemap-label {
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 500;
    flex: 1;
}

.basemap-opacity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 24px;
}

.basemap-opacity-label {
    font-size: 11px;
    color: var(--text-medium);
    white-space: nowrap;
}

.basemap-opacity-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.basemap-opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.basemap-opacity-slider::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
}

.basemap-opacity-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

.basemap-opacity-slider::-moz-range-thumb:hover {
    background: var(--primary-dark);
}

.basemap-opacity-value {
    font-size: 11px;
    color: var(--text-dark);
    font-weight: 600;
    min-width: 30px;
    text-align: right;
}

/* --- Filtre de Refugis Climàtics --- */
#refugis-filter-panel {
    position: absolute;
    top: 10px;
    left: 60px;
    z-index: 800;
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    min-width: 200px;
    max-width: 230px;
}

#refugis-filter-panel.hidden {
    display: none;
}

.refugis-filter-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.refugis-filter-header i {
    color: var(--primary);
    font-size: 13px;
}

.refugis-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 5px 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-dark);
    line-height: 1.35;
}

.refugis-filter-option input[type="radio"] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.refugis-filter-option:hover span {
    color: var(--primary-dark);
}

/* --- Leaflet overrides --- */
.leaflet-control-zoom {
    border: 2px solid var(--primary-light) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-control-zoom a {
    color: var(--primary-dark) !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--bg-sidebar-hover) !important;
}

/* --- Popups personalitzats --- */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
    font-size: 13px;
}

.custom-popup {
    overflow: hidden;
}

.popup-header {
    background: #F0F5FA;
    color: var(--primary-dark);
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 2px solid var(--primary);
}

.popup-body {
    padding: 10px 12px;
    max-height: 300px;
    overflow-y: auto;
}

/* Taula del popup */
.popup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.popup-table tr {
    border-bottom: 1px solid var(--border-color);
}

.popup-table tr:last-child {
    border-bottom: none;
}

.popup-table td {
    padding: 6px 8px;
    line-height: 1.4;
    vertical-align: top;
}

.popup-field {
    font-weight: 600;
    color: var(--primary-dark);
    width: 40%;
    white-space: nowrap;
}

.popup-value {
    color: var(--text-dark);
    width: 60%;
    word-wrap: break-word;
}

.popup-no-data {
    text-align: center;
    color: var(--text-medium);
    font-style: italic;
    padding: 12px;
}

.popup-body::-webkit-scrollbar {
    width: 5px;
}

.popup-body::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}

.leaflet-popup-tip {
    background: var(--white);
}

/* --- Geocoder panel --- */
#geocoder-panel {
    padding: 14px;
}

.geocoder-search {
    margin-bottom: 0;
}

.geocoder-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0 10px;
    transition: border-color 0.2s;
}

.geocoder-input-wrapper:focus-within {
    border-color: var(--primary);
}

.geocoder-search-icon {
    color: var(--text-light);
    font-size: 14px;
    margin-right: 8px;
    flex-shrink: 0;
}

#geocoder-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 13px;
    color: var(--text-dark);
    background: transparent;
    font-family: inherit;
}

#geocoder-input::placeholder {
    color: var(--text-light);
}

#geocoder-clear {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    display: none;
    transition: color 0.2s;
}

#geocoder-clear.visible {
    display: block;
}

#geocoder-clear:hover {
    color: var(--text-dark);
}

/* Input de destí - mateix estil que origen */
#dest-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 0;
    font-size: 13px;
    color: var(--text-dark);
    background: transparent;
    font-family: inherit;
}

#dest-input::placeholder {
    color: var(--text-light);
}

#dest-clear {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    display: none;
    transition: color 0.2s;
}

#dest-clear.visible {
    display: block;
}

#dest-clear:hover {
    color: var(--text-dark);
}

/* Resultats del geocoder */
#geocoder-results {
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
}

#geocoder-results::-webkit-scrollbar {
    width: 5px;
}

#geocoder-results::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}

.geocoder-result-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dark);
    border-bottom: 1px solid #EEF1F5;
    transition: background 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.geocoder-result-item:hover {
    background: var(--bg-sidebar-hover);
}

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

.geocoder-result-item i {
    color: var(--primary);
    margin-top: 2px;
    flex-shrink: 0;
}

.geocoder-result-text {
    flex: 1;
    line-height: 1.3;
}

.geocoder-no-results {
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    font-style: italic;
}

/* Divisor */
.geocoder-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: var(--text-light);
    font-size: 12px;
}

.geocoder-divider::before,
.geocoder-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.geocoder-divider span {
    padding: 0 10px;
    white-space: nowrap;
}

/* Boto clic al mapa */
.geocoder-map-click {
    text-align: center;
    margin-bottom: 14px;
}

.geocoder-map-click button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
}

.geocoder-map-click button:hover {
    background: var(--primary);
    color: var(--white);
}

.geocoder-map-click button.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 0 0 3px rgba(74, 127, 181, 0.3);
}

/* Coordenades */
.geocoder-coords {
    background: var(--white);
    border-radius: 6px;
    padding: 12px;
    border: 1px solid var(--border-color);
}

.geocoder-coords.hidden {
    display: none;
}

.geocoder-coords-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.geocoder-coords-values {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.geocoder-coords-values strong {
    color: var(--primary-dark);
}

#geocoder-remove-marker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: none;
    color: #C0392B;
    border: 1px solid #E8B4AE;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.2s;
}

#geocoder-remove-marker:hover {
    background: #FDEDEB;
    border-color: #C0392B;
}

/* Cursor crosshair quan mode clic actiu */
.map-click-active {
    cursor: crosshair !important;
}

.map-click-active .leaflet-interactive {
    cursor: crosshair !important;
}

/* --- Geocoder steps i opcions --- */
.geocoder-description {
    font-size: 13px;
    color: var(--text-medium);
    line-height: 1.5;
    margin-bottom: 14px;
    padding: 10px 12px;
    background: #F5F9FC;
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.geocoder-step {
    margin-bottom: 10px;
}

.geocoder-step.hidden {
    display: none;
}

.geocoder-step-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.geocoder-step-label i {
    font-size: 12px;
}

/* Origen/Destí seleccionat */
.geocoder-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #EDF4FA;
    border-radius: 6px;
    border: 1px solid var(--primary-light);
    margin-top: 8px;
}

.geocoder-selected.hidden {
    display: none;
}

.geocoder-selected > i {
    color: var(--primary);
    font-size: 16px;
    flex-shrink: 0;
}

.geocoder-selected > span {
    flex: 1;
    font-size: 13px;
    color: var(--text-dark);
    line-height: 1.3;
}

.geocoder-selected > button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
    font-size: 13px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.geocoder-selected > button:hover {
    color: var(--primary-dark);
}

/* Opcions "Què vols saber?" */
.geocoder-options-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-dark);
    margin-top: 16px;
    margin-bottom: 12px;
    text-align: center;
}

.geocoder-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.geocoder-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    transition: all 0.2s;
}

.geocoder-option:hover {
    border-color: var(--primary);
    background: #F5F9FC;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.geocoder-option.selected {
    border-color: var(--primary);
    background: #D6E4F2;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(74, 127, 181, 0.15);
}

.geocoder-option.selected i {
    color: var(--primary);
}

.geocoder-option.selected:hover {
    background: #D6E4F2;
    color: var(--primary);
    transform: none;
}

.geocoder-option i {
    font-size: 20px;
    color: var(--primary);
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.geocoder-option span {
    flex: 1;
    line-height: 1.3;
}

/* Botó calcular ruta */
.route-calculate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #2CA58D, #238C77);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    margin-top: 12px;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(44, 165, 141, 0.3);
}

.route-calculate-btn:hover {
    background: linear-gradient(135deg, #238C77, #1B7A66);
    box-shadow: 0 3px 10px rgba(44, 165, 141, 0.4);
}

.route-calculate-btn.hidden {
    display: none;
}

/* Resultats de ruta */
.route-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.route-result {
    padding: 12px;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.route-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.route-color-line {
    display: inline-block;
    width: 24px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.route-fresh-line {
    background: #2CA58D;
}

.route-short-line {
    background: #F0B429;
}

.route-refuge-line {
    background: #8E44AD;
}

.route-refuge-line.refuge-short {
    background: #F0B429;
}

.route-refuge-line.refuge-fresh {
    background: #2CA58D;
}

.route-result-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.route-valoracio-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 8px;
    margin-bottom: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.route-stat {
    font-size: 12px;
    color: var(--text-medium);
    display: flex;
    align-items: center;
    gap: 6px;
}

.route-stat i {
    color: var(--primary);
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.route-stat strong {
    color: var(--primary-dark);
}

.route-stat-global {
    margin-top: 10px;
    font-size: 13px;
}

.route-stat-global strong {
    font-size: 15px;
}

.route-stat-global strong.score-low  { color: #FF7F7F; }
.route-stat-global strong.score-mid  { color: #FFD37F; }
.route-stat-global strong.score-high { color: #66CDAB; }
.route-stat-global strong.score-top  { color: #219EBC; }

/* Botó netejar rutes */
.route-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    background: none;
    color: #C0392B;
    border: 1px solid #E8B4AE;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}

.route-clear-btn:hover {
    background: #FDEDEB;
    border-color: #C0392B;
}

/* Botó transparència de ruta */
.route-opacity-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    margin-left: auto;
    font-size: 13px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.route-opacity-btn:hover {
    color: var(--text-medium);
}

.route-opacity-btn.active {
    color: var(--primary);
}

/* Control de transparència de ruta (slider) */
.route-opacity-control {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 4px 4px;
    margin-bottom: 4px;
}

.route-opacity-control.visible {
    display: flex;
}

/* Botó ruta evitant pendents */
.route-pendent-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
    padding: 2px 7px;
    background: #f0f4f8;
    border: 1px solid #b0c4d8;
    border-radius: 3px;
    color: #3a5a7a;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s;
}

.route-pendent-btn:hover:not(:disabled) {
    background: #ddeaf5;
    border-color: var(--primary-color);
}

.route-pendent-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.route-pendent-btn.pendent-active {
    background: #e8f4f0;
    border-color: #2CA58D;
    color: #1a6b5a;
}

/* Info de la facility trobada */
.refuge-facility-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(135deg, #E8F5F2, #D4EDE8);
    border-radius: 8px;
    border: 1px solid #A8D8CE;
    margin-bottom: 12px;
    font-weight: 600;
    color: #1B6B56;
    font-size: 14px;
}

.refuge-facility-info i {
    font-size: 18px;
    color: #2CA58D;
}

/* Loading */
.geocoder-loading {
    text-align: center;
    padding: 16px;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
}

.geocoder-loading.hidden {
    display: none;
}

.geocoder-loading i {
    margin-right: 6px;
}

/* --- Control d'informació (baix esquerra, panell integrat com el de mapes base) --- */
#info-control {
    position: fixed;
    bottom: 30px;
    left: calc(var(--sidebar-width) + 10px);
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    z-index: 900;
}

#info-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    transition: background 0.2s;
}

#info-toggle:hover {
    background: var(--bg-sidebar-hover);
}

#info-toggle i {
    color: var(--primary);
    font-size: 16px;
}

#info-options {
    display: none;
    border-top: 1px solid var(--border-color);
    padding: 12px 14px;
    min-width: 240px;
}

#info-options.visible {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted, #999);
    margin-top: 4px;
}

.info-section-title:first-child {
    margin-top: 0;
}

.info-divider {
    border-top: 1px solid var(--border-color);
    margin: 6px 0;
}

.info-contact-text {
    font-size: 12px;
    color: var(--text-medium);
    margin: 0;
}

#info-options a {
    font-size: 12px;
    color: var(--primary-dark);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s;
    padding-left: 8px;
}

#info-options a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.info-email {
    font-weight: 600;
    padding-left: 0 !important;
}

/* =============================================
   Responsive: tablet i mòbil
   ============================================= */

/* Tablet i mòbil en general (<= 768px) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 320px;
        --header-height: 44px;
    }

    /* En mòbil, el logo torna al flux flex per evitar solapament amb el títol */
    #header {
        justify-content: flex-start;
        gap: 10px;
        padding: 0 12px;
    }

    .header-logo-amb {
        position: static;
        transform: none;
        height: 26px;
        flex-shrink: 0;
    }

    .header-title {
        flex: 1;
        text-align: left;
        font-size: 15px;
    }
}

/* --- Mòbil en mode VERTICAL (portrait) ---
   La sidebar ocupa la meitat superior, el mapa la meitat inferior.
   Així el mapa sempre és visible mentre s'usa el cercador. */
@media (max-width: 768px) and (orientation: portrait) {

    #main-container {
        flex-direction: column;
    }

    /* Sidebar al damunt: amplada total, alçada fixada al 50% del que queda */
    #sidebar {
        position: relative;
        width: 100%;
        min-width: 0;
        height: 50%;
        max-height: 50%;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
        z-index: 500;
        transition: height 0.3s ease, max-height 0.3s ease;
    }

    /* Quan està plegada, només es redueix l'alçada (mantenim l'amplada al 100%
       perquè la transició sigui clean i no es vegi un salt lateral). */
    #sidebar.collapsed {
        margin-left: 0;
        width: 100%;
        min-width: 0;
        height: 0;
        max-height: 0;
        overflow: hidden;
        border-bottom: none;
    }

    /* Toggle: pestanya horitzontal entre sidebar i mapa */
    #sidebar-toggle {
        position: fixed;
        top: calc(50vh + (var(--header-height) / 2));
        left: 50%;
        bottom: auto;
        transform: translateX(-50%);
        width: 56px;
        height: 20px;
        border-radius: 0 0 10px 10px;
        border: 1px solid var(--border-color);
        border-top: none;
        font-size: 12px;
        z-index: 1001;
        transition: top 0.3s ease;
    }

    /* Sidebar plegada: el toggle puja a sota la capçalera */
    #sidebar.collapsed #sidebar-toggle {
        top: var(--header-height);
        left: 50%;
    }

    /* Icona del toggle: amunt si la sidebar està oberta (suggereix tancar-la
       cap amunt), avall si està plegada (suggereix obrir-la cap avall) */
    #sidebar-toggle i {
        transform: rotate(-90deg);
        transition: transform 0.2s;
    }

    #sidebar.collapsed #sidebar-toggle i {
        transform: rotate(90deg);
    }

    /* Mapa: ocupa la meitat inferior */
    #map-container {
        flex: 1;
        min-height: 0;
        position: relative;
    }

    /* Inputs amb font-size 16px per evitar zoom automàtic d'iOS al focus */
    #geocoder-input,
    #dest-input {
        font-size: 16px;
    }

    /* Botons d'opció (Què vols saber, tipus refugi, mode...) més tàctils */
    .geocoder-option {
        padding: 14px 14px;
        font-size: 13px;
    }

    /* Dropdown de resultats del geocoder més curt perquè càpiga dins la sidebar */
    #geocoder-results,
    #dest-results {
        max-height: 180px;
    }

    /* Marge inferior addicional al darrer pas perquè es vegi tot amb scroll */
    #geocoder-panel {
        padding-bottom: 24px;
    }

    /* Permetre que la fila amb el desnivell embolqui el botó "Menys pendent"
       a una nova línia si no hi cap horitzontalment */
    .route-stat {
        flex-wrap: wrap;
    }

    .route-pendent-btn {
        margin-left: 0;
        margin-top: 4px;
    }

    /* Sliders d'opacitat més tàctils */
    .opacity-slider {
        height: 6px;
    }

    /* Panells flotants damunt el mapa: ajustar mides per cabre als ~50vh */

    #legend-panel {
        max-width: calc(100vw - 20px);
        max-height: calc(50vh - 80px);
        right: 10px;
        bottom: 10px;
    }

    #legend-content {
        max-height: calc(50vh - 130px);
    }

    /* A mòbil amaguem el panell flotant de capes del cercador i el filtre
       d'equipaments refugi: només els mostrem a la versió desktop */
    #geocoder-layers-panel,
    #refugis-filter-panel {
        display: none !important;
    }

    /* El control de mapa base (top-right fix) està dins l'àrea de la sidebar a portrait;
       el reposicionem al cantó inferior esquerre per no xocar amb la llegenda */
    #basemap-control {
        top: auto;
        bottom: 10px;
        left: 10px;
        right: auto;
    }

    /* Control d'informació: a mòbil va al cantó inferior dret */
    #info-control {
        bottom: 10px;
        left: auto;
        right: 10px;
    }

    #info-toggle {
        padding: 8px 10px;
        font-size: 12px;
    }

    #info-toggle i {
        font-size: 14px;
    }

    #basemap-toggle {
        padding: 8px 10px;
        font-size: 12px;
    }

    #basemap-toggle i {
        font-size: 14px;
    }

    /* Disclaimer del mapa: el text llarg ocuparia massa espai a mòbil portrait;
       l'amaguem perquè el mapa quedi net (l'info segueix accessible al projecte) */
    #map-disclaimer {
        display: none;
    }
}

/* --- Mòbil en mode HORITZONTAL (landscape) ---
   Mantenim layout estil desktop però comprimit, ja que en horitzontal hi ha
   poca alçada disponible i no té sentit dividir-la en dos. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    :root {
        --sidebar-width: 280px;
    }

    #sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 600;
    }

    #sidebar.collapsed {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    /* Inputs amb font-size 16px per evitar zoom d'iOS */
    #geocoder-input,
    #dest-input {
        font-size: 16px;
    }

    /* A mòbil amaguem el panell flotant de capes del cercador i el filtre
       d'equipaments refugi: només els mostrem a la versió desktop */
    #geocoder-layers-panel,
    #refugis-filter-panel {
        display: none !important;
    }

    #legend-panel {
        max-width: 220px;
        max-height: calc(100vh - 80px);
        right: 10px;
        bottom: 10px;
    }

    #legend-content {
        max-height: calc(100vh - 130px);
    }
}

/* =============================================
   Controls de mesura
   ============================================= */

.measure-control {
    margin-top: 0;
}

.info-control {
    position: relative;
}

.measure-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
}

.measure-btn-active {
    background-color: var(--primary) !important;
    color: #ffffff !important;
}

.leaflet-measure-active {
    cursor: crosshair !important;
}

.measure-popup .leaflet-popup-content-wrapper {
    border-radius: 6px;
    padding: 0;
    box-shadow: 0 2px 8px var(--shadow);
}

.measure-popup .leaflet-popup-content {
    margin: 0;
}

.measure-result-popup {
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.measure-result-popup i {
    color: #1d4ed8;
}

/* =============================================
   Modal de benvinguda (versió cercador)
   ============================================= */

.welcome-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
    transition: opacity 0.25s ease;
}

.welcome-modal-overlay.hidden {
    display: none;
}

.welcome-modal {
    position: relative;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    max-width: 640px;
    width: 100%;
    max-height: calc(100vh - 40px);
    padding: 28px 32px;
    overflow-y: auto;
    border-top: 4px solid var(--primary);
}

.welcome-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-medium);
    font-size: 16px;
    transition: background 0.2s, color 0.2s;
}

.welcome-modal-close:hover {
    background: var(--bg-sidebar-hover);
    color: var(--primary-dark);
}

.welcome-modal-title {
    color: var(--primary-dark);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 32px;
}

.welcome-modal-title i {
    color: var(--primary);
}

.welcome-modal-subtitle {
    margin: -4px 0 16px;
}

.welcome-modal-body {
    color: var(--text-dark);
    line-height: 1.55;
    font-size: 14px;
}

.welcome-modal-body p {
    margin-bottom: 12px;
}

.welcome-modal-body h3 {
    color: var(--primary-dark);
    font-size: 15px;
    font-weight: 600;
    margin-top: 14px;
    margin-bottom: 8px;
}

.welcome-modal-body ol {
    padding-left: 22px;
    margin-bottom: 12px;
}

.welcome-modal-body ol > li {
    margin-bottom: 8px;
}

.welcome-modal-body ul {
    padding-left: 18px;
    margin-top: 6px;
    margin-bottom: 6px;
}

.welcome-modal-body ul > li {
    margin-bottom: 4px;
}

.welcome-modal-tip {
    background: #F0F5FA;
    border-left: 3px solid var(--primary);
    padding: 10px 12px;
    border-radius: 4px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-medium);
}

.welcome-modal-tip i {
    color: var(--primary);
    margin-right: 4px;
}

.welcome-modal-tip a {
    color: var(--primary);
}

.welcome-modal-start {
    display: block;
    width: 100%;
    margin-top: 18px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #2CA58D, #238C77);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s;
}

.welcome-modal-start:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(44, 165, 141, 0.35);
}

/* Modal en mòbil portrait: ocupa més pantalla i ajusta padding/grandàries */
@media (max-width: 768px) and (orientation: portrait) {
    .welcome-modal {
        padding: 24px 20px;
        max-height: calc(100vh - 24px);
    }

    .welcome-modal-title {
        font-size: 18px;
    }

    .welcome-modal-body {
        font-size: 13px;
    }
}
