/* ============================================================
   MAPA INTERACTIU NOU — custom-mapa-nou.css
   Patró pres del projecte germà Osoning, adaptat a barraques.
   ============================================================ */

:root {
    --accent: #D2691E;
    --accent-dark: #8B4513;
    --accent-light: rgba(210, 105, 30, 0.1);
}

body { overflow-x: hidden; }

/* Suprimeix el popup natiu de qgis2web — fem servir el panell dret en comptes */
#popup,
.ol-popup {
    display: none !important;
}

.mapa-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 600px;
    width: 100%;
    position: relative;
}

/* ============== CAPÇALERA ============== */
.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: 300px;
    padding: 0 20px 10px;
}
.mapa-capcalera p {
    margin: 0 0 6px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #555;
}
.mapa-capcalera p:last-child { margin-bottom: 0; }

/* ============== FILTRES ============== */
.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;
}
.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;
}

/* ============== LAYOUT PRINCIPAL ============== */
.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-y: auto;
    background: #f8f9fa;
    border-left: 1px solid #ddd;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
    .mapa-info-container { flex-direction: column; }
    .mapa-columna { width: 100%; height: 50vh; }
    .info-columna { width: 100%; height: auto; flex: 1; border-left: none; border-top: 1px solid #ddd; }
}

/* ============== LLISTAT BARRAQUES ============== */
.barraques-llistat {
    padding: 20px;
}
.barraques-llistat h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}
.barraca-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 12px;
}
.barraca-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}
.barraca-card .card-text { flex: 1; min-width: 0; }
.barraca-card h4 {
    margin: 0 0 4px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}
.barraca-card .card-num {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.barraca-card .card-meta {
    margin-top: 6px;
    font-size: 13px;
    color: #6c757d;
}
.barraca-card .card-thumb {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    background-color: #e9ecef;
}
.empty-state {
    color: #6c757d;
    padding: 30px 20px;
    text-align: center;
    font-size: 14px;
}

/* ============== DETALL BARRACA ============== */
.barraca-detall {
    display: none;
    padding: 20px;
}
.barraca-detall.active { display: block; }

#barraques-llistat[data-hidden="true"] { display: none; }

.detall-tornar { margin-bottom: 15px; }
.btn-tornar {
    background: transparent;
    border: 1px solid #6c757d;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}
.btn-tornar:hover {
    background: #6c757d;
    color: white;
}

.detall-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
}
.detall-header h3 {
    margin: 0 0 4px 0;
    font-size: 22px;
    color: #2c3e50;
}
.detall-num-fitxa {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detall-stats {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
}
.detall-stats-3 { grid-template-columns: repeat(3, 1fr); }
.detall-stats-2 { grid-template-columns: repeat(2, 1fr); }

.stat-box {
    background: white;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-box .label {
    font-size: 10px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.stat-box .value {
    font-size: 14px;
    color: #2c3e50;
    font-weight: 600;
}

.detall-section {
    margin: 16px 0;
}
.detall-section h3 {
    font-size: 14px;
    color: #6c757d;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detall-section p {
    margin: 0;
    color: #2c3e50;
    line-height: 1.5;
    font-size: 14px;
}

.btn-enllac {
    display: inline-block;
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.btn-enllac:hover { background: var(--accent-dark); }

.maps-link {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    background: #4285f4;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 12px;
}
.maps-link:hover { background: #3367d6; color: white; }

.fotos-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.fotos-container img {
    width: 100%;
    max-width: 350px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}
.fotos-container img:hover { transform: scale(1.02); }

/* Estat conservació badges (utilitzat en value de stat-box) */
.estat-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: white;
    font-weight: 600;
}
.estat-molt-bo { background: #28a745; }
.estat-bo { background: #5cb85c; }
.estat-regular { background: #ffc107; color: #333; }
.estat-dolent { background: #dc3545; }
.estat-altres { background: #6c757d; }

/* ============== MODAL FOTO ============== */
.foto-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 100000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
.foto-modal.active { display: flex; }
.foto-modal img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
}
.foto-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    background: transparent;
    border: none;
    padding: 0;
    line-height: 1;
}

/* ============== MULTI-SELECT DROPDOWNS ============== */
.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: var(--accent); }
.multi-select-display.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(210, 105, 30, 0.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 span { font-size: 14px; color: #495057; }
