/* RESET GENERALE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: white;
    color: #333;
    line-height: 1.6;
}
/* Riduce margine e line-height per i testi nel box prodotto */
.product-box p,
.product-box h3 {
  margin: 5px 0;       /* Riduce lo spazio verticale */
  line-height: 1.3;    /* Diminuisce la distanza tra le righe */
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
}

/* FILTRI */
.filters {
    text-align: center;
    margin: 40px 0 30px; /* Tienilo se vuoi lo spazio, ma non dovrebbe alterare l’allineamento */
  }


.filter-buttons {
    display: flex;
    justify-content: center; /* Centra i pulsanti */
    flex-wrap: wrap;
    gap: 15px; /* Spaziatura tra i pulsanti */
    margin: 0 auto; /* Facoltativo per sicurezza */
  }

.filter-btn {
    padding: 12px 24px;
    background-color: #e63946;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease, transform 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    background-color: #d62828;
    transform: translateY(-3px);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 colonne su desktop */
    gap: 30px;

    /* Queste due proprietà servono a centrare gli elementi all’interno di ciascuna cella */
    justify-items: center;
    align-items: start; /* O center se vuoi verticalmente centrato */

    /* Se vuoi anche l’intera griglia centrata nel container, puoi provare: */
    justify-content: center;
  }


.product-box {
    width: 280px;
    text-align: center;
    position: relative;
    cursor: pointer;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}

.product-box:hover {
    transform: translateY(-10px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.image-container {
    width: 100%;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    position: relative;
    overflow: visible;
    padding: 10px;
    box-sizing: border-box;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    border-radius: 6px;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    margin: auto;
    display: block;
    position: relative;
}

.text-container {
    padding: 15px;
}

.text-container h3 {
    font-size: 1.1rem;
    margin: 0 0 8px 0;
    color: #333;
    line-height: 1.3;
}

.price-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}



.product-box h3 {
    margin: 15px 0;
    font-size: 1.2rem;
    color: #333;
}

/* SHOWBOX (MODALE INGRANDIMENTO) */
.showbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.showbox.hidden {
    display: none;
}

.showbox-content {
    background-color: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 1000px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Slider container */
.showbox-slider {
    width: 100%;
    min-height: 300px;
    background-color: #f8f8f8;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    position: relative;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Immagini nello slider */
.showbox-slider .slide {
    display: none;
    width: 100%;
    height: 100%;
    text-align: center;
}

.showbox-slider .slide.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.showbox-slider .slide img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}



/* Stile per il caricamento delle immagini */
.showbox-slider img.loading {
    opacity: 0.5;
}

/* Indicatore di caricamento - mostrato solo quando necessario */
.showbox-slider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #e63946;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Mostra lo spinner solo quando ci sono immagini in caricamento */
.showbox-slider:has(img.loading)::before {
    opacity: 1;
}

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

.showbox-slider img:hover {
    transform: scale(1.05) !important;
}

.showbox-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    text-align: left;
    padding: 0 20px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.showbox-content h3 {
    margin: 0;
    font-size: 2rem;
    color: #111;
    border-bottom: 2px solid #e63946;
    padding-bottom: 10px;
    font-weight: 700;
}

/* Stile per la descrizione formattata */
#showbox-description {
    text-align: left;
    line-height: 1.6;
    margin: 15px 0;
}

#showbox-description p {
    margin-bottom: 1em;
}

#showbox-description br {
    margin-bottom: 0.5em;
    display: block;
    content: "";
}

.showbox-content h4 {
    font-size: 1.3rem;
    color: #333;
    margin: 5px 0;
    font-weight: 600;
}

.showbox-content p {
    color: #555;
    font-size: 1.1rem;
    line-height: 1.6;
}

.description-container {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
    border-left: 4px solid #e63946;
}

#showbox-price {
    font-size: 1.2rem;
    font-weight: 600;
}

#showbox-price .discounted-price {
    font-size: 1.4rem;
}

#showbox-brand {
    font-style: italic;
    color: #666;
}

/* PULSANTE DI CHIUSURA */
.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #333;
    background-color: #f0f0f0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
}

.close-btn:hover {
    transform: rotate(90deg);
    background-color: #e63946;
    color: white;
}

/* PULSANTI PREV/NEXT NEL MODALE */
.prev, .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
    border: none;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.prev:hover,
.next:hover {
    background-color: #e63946;
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.prev {
    left: 20px;
}

.next {
    right: 20px;
}

/* INDICATORI (DOTS) PER LO SLIDER */
.dots-container {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 0;
}

.dot {
    width: 14px;
    height: 14px;
    background-color: #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.dot:hover {
    transform: scale(1.2);
    background-color: #ccc;
}

.dot.active {
    background-color: #e63946;
    transform: scale(1.2);
    box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.3);
}

/* Media query per responsività */
@media (max-width: 1200px) {
    .showbox-content {
        max-width: 90%;
    }
    
    .showbox-slider img {
        max-height: 350px;
    }
}

@media (max-width: 992px) {
    .showbox-slider img {
        max-height: 300px;
    }
    
    .showbox-content h3 {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    .showbox-content {
        padding: 20px;
        width: 95%;
        gap: 15px;
    }
    
    .showbox-slider {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .showbox-slider img {
        max-height: 250px;
    }
    
    .showbox-content h3 {
        font-size: 1.5rem;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    
    .showbox-content h4 {
        font-size: 1.2rem;
    }
    
    .showbox-content p {
        font-size: 1rem;
    }
    
    .prev, .next {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

@media (max-width: 576px) {
    .showbox-content {
        padding: 15px;
        width: 98%;
    }
    
    .showbox-slider {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .showbox-slider img {
        max-height: 200px;
    }
    
    .showbox-info {
        padding: 0 5px;
    }
    
    .showbox-content h3 {
        font-size: 1.3rem;
        padding-bottom: 5px;
        margin-bottom: 5px;
    }
    
    .description-container {
        padding: 8px;
    }
    
    .prev, .next {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .close-btn {
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
        top: 10px;
        right: 10px;
    }
}

/* RESPONSIVE DESIGN */
@media (max-width: 992px) {
    .product-grid {
      grid-template-columns: repeat(3, 1fr); /* 3 colonne su tablet medio */
    }
  }

@media (max-width: 768px) {
    .product-box {
        width: 90%;
    }

    .filter-buttons {
        gap: 10px;
    }

    .filter-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    .showbox-content {
        width: 90%;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 colonne su tablet più piccolo */
      }

}

@media (max-width: 480px) {
    .filter-btn {
        width: 100%;
    }

    .product-box {
        width: 100%;
    }

    .prev, .next {
        font-size: 1.5rem;
        padding: 8px;
    }

    .close-btn {
        font-size: 2rem;
        right: 15px;
    }

    .product-grid {
        grid-template-columns: 1fr; /* 1 colonna su smartphone */
      }

}

/* Stile del select */
#filter-select {
    padding: 10px;
    font-size: 16px;
    border: 2px solid #e63946;
    border-radius: 5px;
    background-color: white;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

#filter-select:hover {
    border-color: #d62828;
}

/* Centrare il bottone "Carica Altri" */
.load-more-container {
    text-align: center; /* Centra il contenuto */
    margin-top: 20px;
}

#load-more {
    padding: 12px 24px;
    background-color: #e63946;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease, transform 0.2s;
    display: inline-block; /* Per allinearlo correttamente */
    margin: 0 auto;
}

#load-more:hover {
    background-color: #d62828;
    transform: translateY(-3px);
}
