/* ============================================
   RESPONSIVE DESIGN - GUSTCAT
   Optimitzat per mòbil primer
   ============================================ */

/* DESKTOP GRAN (1201px+) */
@media (min-width: 1201px) {
    .header-content { height: 85px; }
    .logo { width: 50%; height: 85px; }
    .logo-icon img { height: 65px; }
    nav { width: 50%; height: 85px; }
}

/* PORTÀTILS (901px - 1200px) */
@media (max-width: 1200px) and (min-width: 901px) {
    .header-content { height: 70px; padding: 0 1rem; gap: 1rem; }
    .logo { width: auto; height: 70px; flex-shrink: 0; }
    .logo-icon img { height: 50px; }
    nav { width: auto; flex: 1; height: 70px; justify-content: flex-end; }
    nav ul { gap: 0.2rem; }
    nav a { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
    .btn-primary { padding: 0.5rem 0.8rem; font-size: 0.8rem; }
}

/* TABLETS (769px - 900px) */
@media (max-width: 900px) and (min-width: 769px) {
    .header-content { height: 65px; padding: 0 1rem; }
    .logo { width: 30%; height: 65px; }
    .logo-icon img { height: 45px; }
    nav { width: 70%; height: 65px; justify-content: flex-end; }
    nav ul { gap: 0.1rem; }
    nav a { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
    .btn-primary { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    
    .search-container { grid-template-columns: 1fr; gap: 1rem; }
    .commerce-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
    
    .category-filters {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 0.5rem;
    }
}

/* ============================================
   MÒBIL (MAX 768px)
   ============================================ */
@media (max-width: 768px) {
    /* BASE */
    body { overflow-x: hidden; }
    
    /* HEADER */
    header { padding: 0.5rem 0; }
    .header-content {
        flex-direction: column;
        height: auto;
        padding: 0.5rem;
        gap: 1rem;
        width: 100%;
    }
    
    .logo {
        width: 100%;
        height: 60px;
        justify-content: center;
    }
    
    .logo-icon img { height: 50px; }

 
    nav {
        width: 100%;
        height: auto;
        justify-content: center;
    }
    
    nav ul {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
        max-width: 400px;
        margin: 0;
    }
    
    nav li:last-child { grid-column: 1 / -1; }
    
    nav a {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
        text-align: center;
        border-radius: 8px;
    }
    
    .btn-primary {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }
    
    /* HERO */
    .hero { padding: 3rem 1rem; text-align: center; }
    .hero h1 { font-size: 2rem; line-height: 1.3; margin-bottom: 1.5rem; }
    .hero p { font-size: 1.1rem; margin-bottom: 2rem; }
    
    .hero > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .hero .btn-primary { max-width: 300px; margin: 0 auto; }
    
/* CERCA */
.search-section {
    padding: 1.5rem;
    margin: -2rem 1rem 2rem;
    width: calc(100% - 2rem);
    box-sizing: border-box;
}

.map-search-section {
    padding: 1.5rem;
    padding-top: 2.5rem; /* Espai extra per evitar que el header la tapi */
    margin: 0 1rem 1rem;
    width: calc(100% - 2rem);
    box-sizing: border-box;
}
    
    .search-container,
    .search-container-map {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100%;
    }
    
    .search-input,
    select {
        width: 100%;
        font-size: 16px;
        min-height: 50px;
        padding: 1rem;
        box-sizing: border-box;
    }
    
    .favorites-map-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    /* SECTIONS */
    section[style*="padding: 6rem 2rem"] { padding: 4rem 1.5rem !important; }
    
    div[style*="grid-template-columns: repeat(auto-fit, minmax(350px, 1fr))"] {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
    
    /* TARGETES */
    .commerce-card {
        min-height: auto;
        margin-bottom: 1.5rem;
    }
    
    .commerce-header { padding: 2rem 1.5rem; }
    .commerce-header h3 { font-size: 1.4rem; line-height: 1.3; }
    .commerce-body { padding: 1.5rem; }
    
    .commerce-footer {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1.2rem;
        text-align: center;
    }
    
    .commerce-actions-row {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .action-btn { margin: 0.2rem; }
    
    .product-content { display: block; }
    
    .product-image {
        width: 100%;
        max-width: 250px;
        height: 180px;
        margin: 1rem auto 0;
        display: block;
    }
    
    /* RESULTATS */
    .results-section {
        padding: 0 1rem 2rem;
        width: calc(100% - 2rem);
    }
    
    .results-header {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
        padding: 1.5rem;
    }
    
    .results-header h2 { font-size: 1.8rem; }
    .commerce-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    
    /* MAPA - Contenidor principal */
    .map-container {
        display: flex;
        flex-direction: column;
        padding: 0;
        margin: 0;
        width: 100%;
    }
    
    #map {
        order: 1;
        height: calc(100vh - 280px);
        width: 100%;
    }
    
    /* FILTRES MAPA - Panel lateral ocult */
    .filters-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        background: var(--bg-white);
        z-index: 999;
        overflow-y: auto;
        transition: left 0.3s ease;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
        padding: 1.5rem;
        margin: 0;
    }
    
    .filters-sidebar.active { left: 0; }
    
    .category-filters {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        width: 100%;
    }
    
    .category-filter {
        padding: 1rem !important;
        border: 2px solid var(--border-color) !important;
        border-radius: 10px !important;
        background: var(--bg-light);
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
    }
    
    /* Categoria seleccionada - VERD */
    .category-filter:has(input:checked) {
        background: #E8F5E9 !important;
        border-color: #4CAF50 !important;
        box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2) !important;
    }
    
    .category-filter input[type="checkbox"] {
        width: 24px !important;
        height: 24px !important;
        margin-right: 1rem !important;
        cursor: pointer;
        flex-shrink: 0;
        accent-color: #4CAF50;
    }
    
    .category-filter label {
        font-size: 0.95rem !important;
        font-weight: 500 !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.8rem !important;
        width: 100% !important;
        cursor: pointer;
    }
    
    .category-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
        flex-shrink: 0;
    }
    
    /* MARCADORS MAPA */
    .custom-marker {
        width: 30px !important;
        height: 30px !important;
        font-size: 14px !important;
    }
    
/* ============================================
       CLUSTERS MÒBIL - ARREGLATS I VISIBLES
       ============================================ */
    
    /* Contenidor exterior - Més gran i visible */
    .marker-cluster {
        background: radial-gradient(circle, rgba(76, 175, 80, 0.4) 0%, rgba(76, 175, 80, 0.15) 60%, transparent 100%) !important;
    }
    
    /* Cercle interior - Centrat i amb vora gruixuda */
    .marker-cluster div {
        box-shadow: 0 4px 16px rgba(76, 175, 80, 0.7), 0 0 0 4px white !important;
        margin: 0 !important;
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
    }
    
    /* ===== CLUSTER PETIT ===== */
    .marker-cluster-small {
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }
    
    .marker-cluster-small div {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        margin: 7px auto !important;
    }
    
    .marker-cluster-small span {
        font-size: 16px !important;
        line-height: 42px !important;
    }
    
    /* ===== CLUSTER MITJÀ ===== */
    .marker-cluster-medium {
        width: 64px !important;
        height: 64px !important;
        min-width: 64px !important;
        min-height: 64px !important;
    }
    
    .marker-cluster-medium div {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        margin: 8px auto !important;
    }
    
    .marker-cluster-medium span {
        font-size: 18px !important;
        line-height: 48px !important;
    }
    
    /* ===== CLUSTER GRAN ===== */
    .marker-cluster-large {
        width: 72px !important;
        height: 72px !important;
        min-width: 72px !important;
        min-height: 72px !important;
    }
    
    .marker-cluster-large div {
        width: 54px !important;
        height: 54px !important;
        min-width: 54px !important;
        min-height: 54px !important;
        margin: 9px auto !important;
    }
    
    .marker-cluster-large span {
        font-size: 20px !important;
        line-height: 54px !important;
    }
   
    
    /* POPUPS */
    .leaflet-popup-content-wrapper {
        width: 280px !important;
        max-width: 90vw !important;
    }
    
    .leaflet-popup-content { margin: 8px !important; }
    .popup-content h4 { font-size: 1rem !important; }
    .popup-actions button { padding: 0.5rem !important; font-size: 0.9rem !important; }
    .popup-btn-secondary { padding: 0.6rem 0 !important; }
    
    /* MODALS */
    .modal-content { width: 95%; margin: 2% auto; }
    .modal-body { max-height: 70vh; padding: 1.5rem; }
    
    /* FORMULARIS */
    .section { padding: 0 1rem; width: calc(100% - 2rem); }
    .form-card { padding: 1.5rem; }
    .form-grid { grid-template-columns: 1fr; }
    
/* FOOTER */
.footer-content {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr;
    gap: 2.5rem;
    text-align: center;
    padding: 2rem 1rem;
    max-width: 100%;
}

.footer-section {
    width: 100%;
    padding: 0;
    flex: none !important;
}

.footer-section h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.footer-section ul {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
}

.footer-section ul li {
    width: 100%;
    max-width: 300px;
}

.footer-section ul li a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem;
    font-size: 0.95rem;
}

.footer-section p {
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

.social-links {
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
}

.footer-bottom {
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem 1rem;
}

.footer-bottom p {
    font-size: 0.85rem;
    line-height: 1.5;
}

.language-selector {
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.language-btn {
    flex: 0 1 auto;
    min-width: 120px;
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
}
   
}

/* MÒBIL PETIT (MAX 480px) */
@media (max-width: 480px) {
    .hero h1 { font-size: 1.8rem; }
    .search-section { padding: 1rem; margin: -1.5rem 0.5rem 1.5rem; }
    .commerce-header, .commerce-body, .form-card { padding: 1rem; }
    nav a { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
    .btn-primary { padding: 0.5rem 1rem; font-size: 0.85rem; }
}

/* ============================================
   BOTÓ FLOTANT FILTRES (només mòbil)
   ============================================ */
.mobile-filters-toggle {
    display: none;
}

.mobile-filters-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-filters-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-filters-close { display: none; }

@media (max-width: 768px) {
    .mobile-filters-toggle {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: linear-gradient(135deg, #8B4513, #A0522D);
        color: white;
        border: none;
        border-radius: 50px;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
        box-shadow: 0 6px 20px rgba(139, 69, 19, 0.4);
        cursor: pointer;
        z-index: 999;
        align-items: center;
        gap: 0.5rem;
        transition: all 0.3s ease;
    }
    
    .mobile-filters-toggle:active {
        transform: scale(0.95);
    }
    
    .mobile-filters-close {
        display: block;
        background: var(--accent-color);
        color: white;
        border: none;
        border-radius: 8px;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 1.5rem;
        width: 100%;
        transition: all 0.2s ease;
    }
    
    .mobile-filters-close:active {
        background: #FF8C42;
        transform: scale(0.98);
    }

   /* MODAL PANTALLA COMPLETA EN MÒBIL */
    .modal {
        background-color: rgba(0,0,0,0.95) !important;
    }
    
    .modal-content {
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        max-width: 100% !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .modal-header {
        flex-shrink: 0;
        padding: 1rem !important;
        position: relative;
    }
    
    .modal-header h2 {
        font-size: 1.3rem !important;
        padding-right: 50px;
    }
    
    /* Botó tancar visible i gran */
    .close {
        display: flex !important;
        position: absolute !important;
        top: 1rem !important;
        right: 1rem !important;
        font-size: 2rem !important;
        width: 45px !important;
        height: 45px !important;
        background: rgba(255, 255, 255, 0.2) !important;
        border-radius: 50% !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 1001 !important;
    }
    
    .modal-body {
        flex: 1;
        overflow-y: auto !important;
        padding: 1rem !important;
        max-height: none !important;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Imatges producte més grans en modal mòbil */
    .modal-body img {
        max-width: 100% !important;
        height: auto !important;
    }
}
