/* ========================================
   PRODUCTS.CSS - Product Cards, Grid, Carousel
   ======================================== */

/* SIDEBAR MODERNA (desktop) */
.sidebar {
    width: 260px;
    background: #f9f9f9;
    padding: 24px 16px;
    border-right: 1px solid #ddd;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 20px;
}

.catalogo-titolo {
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.spacer-link {
    height: 20px;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.back-link,
.back-static {
    font-size: 14px;
    margin-bottom: 4px;
    display: inline-block;
    color: #007BFF;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.back-static {
    color: #888;
    cursor: default;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid #ddd;
    margin: 10px 0 16px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    padding-bottom: 100px;
}

.sidebar ul li {
    margin-bottom: 6px;
}

.sidebar ul li:last-child {
    margin-bottom: 90px;
}

.sidebar ul li a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    background-color: transparent;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar ul li a:hover {
    background-color: #e6f0fa;
    color: #0057A0;
}

.sidebar ul li a:active {
    background-color: #dce9f8;
}

.sidebar ul li a.active {
    background-color: #d0e4fa;
    color: #004080;
    font-weight: 600;
}

.sidebar ul li span.active {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    background-color: #d0e4fa;
    color: #004080;
    font-size: 14px;
    font-weight: 600;
}

/* PRODUCT GRID */
.products-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, 1fr);
    padding: 0 10px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Quando le card sono tagliate, forza lo scroll a livello di body */
body.has-scroll {
    overflow-x: auto !important;
}

body.has-scroll::-webkit-scrollbar {
    height: 12px;
}

body.has-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}

body.has-scroll::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 6px;
}

body.has-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

.products-grid.has-scroll {
    overflow-x: visible !important;
    grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
}

@media (min-width: 676px) {
    .products-grid.has-scroll {
        grid-template-columns: repeat(3, minmax(260px, 1fr)) !important;
    }
}

@media (min-width: 1200px) {
    .products-grid.has-scroll {
        grid-template-columns: repeat(4, minmax(280px, 1fr)) !important;
    }
}

/* Scroll orizzontale quando le card sono tagliate - applicato al content */
.content.has-scroll {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
}

.content.has-scroll::-webkit-scrollbar {
    height: 12px;
}

.content.has-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.content.has-scroll::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 6px;
}

.content.has-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

/* Quando lo scroll è attivo, forza una larghezza minima alle card */
.content.has-scroll .products-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
}

@media (min-width: 676px) {
    .content.has-scroll .products-grid {
        grid-template-columns: repeat(3, minmax(260px, 1fr)) !important;
    }
}

@media (min-width: 1200px) {
    .content.has-scroll .products-grid {
        grid-template-columns: repeat(4, minmax(280px, 1fr)) !important;
    }
}

/* Assicuriamoci che anche su mobile il comportamento sia corretto */
@media (max-width: 992px) {
    .content.has-scroll {
        overflow-x: auto !important;
        overflow-y: visible !important;
    }
}

@media (min-width: 676px) {
    .products-grid {
        grid-template-columns: repeat(3, minmax(260px, 1fr));
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(4, minmax(280px, 1fr));
        gap: 20px;
    }
}


.product-card {
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 6px;
    background-color: white;
    transition: box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    height: 440px;
    overflow: hidden;
}

.product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* BLOCCO IMMAGINE */
.product-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.product-image img,
.product-image .no-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #999;
    background: #e0e0e0;
}

/* CONTENUTO TESTUALE */
.ean {
    font-size: 10px;
    color: #bbb;
    margin-bottom: 4px;
}

.product-card h4 {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-card p {
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.3;
}

.product-card .descrizione {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 2.6em;
}

.info-riga {
    font-size: 14px;
    color: #555;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 6px;
}

.info-riga i {
    margin-right: 4px;
    color: #888;
}

.prezzo {
    font-size: 18px!important;
    font-weight: bold;
    margin: 6px 0 4px 0;
}

.prezzo-info {
    font-size: 12px;
    color: #007BFF;
    margin-left: 6px;
}

.product-card .imballo,
.product-card .giacenza {
    font-size: 13px;
    margin-top: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.giacenza.verde {
    color: green;
    font-weight: 800!important;
}

.giacenza.arancione {
    color: rgb(216, 86, 0);
    font-weight: 800!important;
}

.quantita-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 8px;
}

.quantita-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.quantita-controls input.input-quantita {
    width: 50px;
    text-align: center;
    padding: 5px;
}

.input-note {
    width: 100%;
    min-height: 38px;
    resize: none;
    padding: 6px 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    text-align: center;
}

.input-note::placeholder {
    text-align: center;
    color: #aaa;
}

.input-note:disabled {
    display: none;
}

.input-note:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

.btn-qty {
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    cursor: pointer;
    border-radius: 4px;
}

.btn-qty:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-message {
    font-size: 13px;
    color: #c00;
    margin-top: 10px;
    text-align: center;
}

/* BARRA FILTRI */
.filters-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    background: #f7f9fc;
    border-bottom: 1px solid #ccc;
    padding: 12px 16px;
    margin-bottom: 20px;
    gap: 10px;
}

.filter-count-small {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.filters-left {
    justify-self: start;
}

.filters-center {
    justify-self: center;
}

.filters-right {
    justify-self: end;
}

.filters-left,
.filters-center {
    flex: 1;
    min-width: 250px;
}

.filters-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    font-size: 13px;
}

.filters-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-breadcrumbs {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #333;
}

.filter-breadcrumbs a {
    font-style: italic;
    color: #007BFF;
    text-decoration: none;
}

.filter-breadcrumbs a:hover {
    text-decoration: underline;
}

.filter-breadcrumbs .filter-static {
    font-weight: bold;
    color: #007BFF;
}

.filter-count {
    margin: 0;
    font-size: 12px;
}

.filters-bar a {
    color: #007BFF;
    text-decoration: none;
    font-style: italic;
}

.filters-bar a:hover {
    text-decoration: underline;
}

.filter-link {
    color: #007BFF;
    text-decoration: none;
    font-weight: normal;
}

.filter-link:hover {
    text-decoration: underline;
}

.filter-static {
    font-weight: bold;
    color: #007BFF;
    text-decoration: none;
    cursor: default;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
    min-width: 300px;
}

.search-wrapper input {
    flex: 1;
    padding: 8px 34px 8px 10px;
    border: 1px solid #aaa;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    height: 38px;
}

.search-wrapper button[type="submit"] {
    height: 38px;
    padding: 0 14px;
    background: #f3f3f3;
    border: 1px solid #aaa;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#clearSearch {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    display: none;
    padding: 0;
    line-height: 1;
}

.search-result-info {
    background: #f0f0f0;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-result-info em {
    color: #007BFF;
}

.clear-search {
    margin-left: 10px;
    font-size: 18px;
    color: crimson!important;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
}

.clear-search:hover {
    color: darkred;
}

.pagination-controls select {
    padding: 6px 10px;
    font-size: 13px;
    height: 34px;
    border: 1px solid #aaa;
    border-radius: 4px;
    background-color: #fff;
    appearance: none;
    cursor: pointer;
}

.pagination-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pagination-controls .arrow {
    font-size: 18px;
    text-decoration: none;
    padding: 6px 10px;
    border: 1px solid #aaa;
    border-radius: 4px;
    color: #007bff;
    background-color: #fff;
    transition: background-color 0.2s, border-color 0.2s;
}

.pagination-controls .arrow:hover {
    background-color: #e6f0fb;
    border-color: #007bff;
    color: #0056b3;
    text-decoration: none;
}

.pagination-controls .arrow.disabled {
    pointer-events: none;
    color: #aaa;
    border-color: #ccc;
    background-color: #f3f3f3;
}

.custom-pagination-wrapper {
    margin: 30px auto;
    display: flex;
    justify-content: center;
}

/* HERO BANNER */
.hero-banner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 30px;
    aspect-ratio: 2 / 1;
    background: #000;
    position: relative;
    overflow: hidden;
}

.hero-banner button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background-color: #0057A0;
    color: white;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.3s, transform 0.2s;
}

.hero-banner button:hover {
    background-color: #003e73;
    transform: translateY(-50%) scale(1.1);
}

.hero-banner .prev {
    left: 16px;
}

.hero-banner .next {
    right: 16px;
}

.slider-track a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.slider-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.slider-track {
    display: flex;
    height: 100%;
    transition: transform 0.5s ease-in-out;
    width: 100%;
}

.slider-track>* {
    flex: 0 0 100%;
    height: 100%;
    box-sizing: border-box;
}

.slide-video video,
.slider-track img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

.slide-image,
.slide-video {
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    position: relative;
}

.slide-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #000;
}

/* PROMOZIONI SECTION */
.promozioni {
    margin: 60px 0;
    padding: 0 20px;
}

.titolo-promozioni {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #0057A0;
    margin-bottom: 24px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.promo-carousel {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 24px;
    scrollbar-gutter: stable;
}

.carousel-track {
    display: flex;
    gap: 16px;
    min-width: 100%;
}

.carousel-track .product-card {
    flex: 0 0 auto;
    width: 240px;
}

/* Mobile: 2 schede prodotto visibili interamente (come in shop), barra scroll per le altre */
@media (max-width: 768px) {
    .promozioni .carousel-track .product-card {
        width: calc(50vw - 28px);
        min-width: 120px;
    }
    .promozioni .carousel-track .product-card .product-image {
        aspect-ratio: 4 / 3;
    }
}

.promo-carousel::-webkit-scrollbar {
    height:40px;
}

.promo-carousel::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 8px;
}

.promo-carousel::-webkit-scrollbar-thumb {
    background-color: red;
    border-radius: 20px;
    border: 5px solid yellow;
}

.promo-carousel {
    scrollbar-width: auto;
    scrollbar-color: #0057A0 #e0e0e0;
}

/* CATEGORIE PRINCIPALI HOME */
.titolo-categorie {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #0057A0;
    margin-bottom: 34px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.categorie-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 0 20px;
}

.categoria-box {
    position: relative;
    background-size: cover;
    background-position: center;
    min-height: 250px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    color: white;
    transition: transform 0.3s ease;
}

.categoria-box::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
    z-index: 1;
}

.categoria-box span {
    position: relative;
    z-index: 2;
    font-size: 18px;
    font-weight: 600;
    padding: 12px 16px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.categoria-box:hover {
    transform: scale(1.02);
}

/* LIGHTBOX */
#lightboxOverlay {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
}

#lightboxOverlay.show {
    display: flex !important;
}

#lightboxOverlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
    margin: auto;
    display: block;
}

.info-box {
    margin-top: 16px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.45;
}

.info-title {
    margin: 0 0 8px 0;
    font-size: 1rem;
}

.info-list {
    margin: 0;
    padding-left: 18px;
}

.info-list>li {
    margin: 4px 0;
}

.info-sublist {
    margin: 6px 0 0 16px;
    padding-left: 18px;
}

.badge-free {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e6ffed;
    border: 1px solid #b7f5c5;
    font-weight: 600;
}

