/* ================================
   Catalogo Prodotti - Rejna
   ================================ */

/* Contenitore principale */
.content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Titolo pagina */
.content h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    text-align: center;
}

/* ================================
   Sezione Filtri
   ================================ */
.filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Barra ricerca */
.search-bar {
    display: flex;
    justify-content: center;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 6px rgba(0,0,0,0.1);
}

/* Filtri categorie */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.categories button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--light-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-size: 0.95rem;
}

.categories button:hover {
    background: var(--primary-light);
    color: #fff;
}

.categories button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    font-weight: bold;
}

/* ================================
   Griglia Prodotti
   ================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    justify-content: center;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 0;
}

/* Card prodotto */
.product-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    min-height: 420px;
    box-sizing: border-box;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

/* ================================
   Immagini Prodotto (dimensione fissa)
   ================================ */
.product-image-wrapper {
    width: 100%;
    height: 200px; /* altezza fissa */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-sm);
    background: #fafafa;
}

.product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* mantiene proporzioni e riempie contenitore */
    object-position: center;
}

/* ================================
   Info prodotto
   ================================ */
.product-info {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-sizing: border-box;
}

/* Nome prodotto (2 righe min + ellissi se troppo lungo) */
.product-info h3 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
    color: #43464B;
    min-height: 2.8em; /* almeno 2 righe */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Link titolo */
.product-info h3 a {
    color: #43464B;
    text-decoration: none;
    transition: color 0.2s ease;
}

.product-info h3 a:hover {
    color: var(--primary-color);
}

/* Descrizione con ellissi - 2 righe */
.product-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* massimo 2 righe */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.5rem;
}

/* Prezzo */
.product-info p {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.product-info strong {
    color: var(--primary-color);
    font-size: 1.1rem;
}

/* Form aggiunta al carrello */
.product-info > form {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ================================
   Quantità + Pulsante Carrello
   ================================ */
.quantity-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem 0;
}

.qty-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--light-bg);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}

.qty-btn:hover {
    background: var(--primary-light);
    color: #fff;
}

.quantity-wrapper input[type="number"] {
    width: 60px;
    text-align: center;
    padding: 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    appearance: textfield;
}

.quantity-wrapper input::-webkit-inner-spin-button,
.quantity-wrapper input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Pulsante aggiungi al carrello */
.btn-add-cart {
    background: linear-gradient(145deg, var(--primary-color), var(--primary-dark, #1e3a8a));
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    border-radius: var(--radius-md);
    padding: 0.7rem 1.2rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

.btn-add-cart:hover {
    background: linear-gradient(145deg, var(--primary-light), var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    color: #fff;
}

.btn-add-cart:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ================================
   Media Query per Smartphone
   ================================ */
@media (max-width: 520px) {
    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 1rem;
        justify-content: center;
    }

    .product-card {
        min-height: 320px;
    }

    .product-image-wrapper {
        height: 140px;
    }

    .product-image-wrapper img {
        height: 100%;
    }

    .product-info h3 {
        font-size: 1.1rem;
        min-height: 2.4em;
        -webkit-line-clamp: 2;
    }

    .product-desc {
        font-size: 0.85rem;
        -webkit-line-clamp: 2; /* massimo 2 righe anche su mobile */
    }

    .quantity-wrapper input[type="number"] {
        width: 50px;
    }

    .btn-add-cart {
        font-size: 0.95rem;
        padding: 0.5rem 0.8rem;
    }
}
