/**
 * LYG Categories Display - Main Styles
 * Responsive slider for WooCommerce categories
 */

/* ===========================
   Mobile Margin (Header Offset)
   =========================== */
@media (max-width: 1023px) {

    /* Per Elementor Canvas (che parte da 0px) serve lo spazio intero dell'header */
    body.elementor-template-canvas .lyg-categories-wrapper {
        margin-top: 0 !important;
        padding-top: 80px !important;
    }

    /* Per le Pagine native del Tema (Shop, Prodotto, ecc.) che hanno già una spaziatura parziale, compensiamo solo il resto (es. 30px) */
    body:not(.elementor-template-canvas) .lyg-categories-wrapper {
        margin-top: 0 !important;
        padding-top: 30px !important;
    }
}

/* ===========================
   Main Container
   =========================== */
.lyg-categories-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Nasconde solo l'overflow orizzontale per permettere all'anello di mostrarsi verticalmente */
    overflow-x: clip;
    overflow-y: visible;
}

/* ===========================
   Navigation Arrows (Desktop)
   =========================== */
.lyg-nav-btn {
    display: none !important;
    flex-shrink: 0 !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    border-radius: 50% !important;
    background: #111 !important;
    background-color: #111 !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    z-index: 10 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35) !important;
    line-height: 1 !important;
    outline: none !important;
}

/* Freccia comune via border CSS */
.lyg-nav-btn .lyg-arrow {
    display: block !important;
    width: 5px !important;
    height: 5px !important;
    border-top: 2px solid #fff !important;
    border-right: 2px solid #fff !important;
    border-left: none !important;
    border-bottom: none !important;
    background: transparent !important;
}

/* Freccia sinistra: ruotata 225deg (punta a sinistra) */
.lyg-nav-prev .lyg-arrow {
    transform: rotate(225deg) !important;
    margin-left: 2px !important;
}

/* Freccia destra: ruotata 45deg (punta a destra) */
.lyg-nav-next .lyg-arrow {
    transform: rotate(45deg) !important;
    margin-right: 2px !important;
}

.lyg-nav-btn:hover {
    background: #333 !important;
    background-color: #333 !important;
    transform: scale(1.08);
}

.lyg-nav-btn:focus-visible {
    outline: 2px solid #007cba !important;
    outline-offset: 2px !important;
}

/* Stato "disabilitato" quando si è all'inizio o alla fine */
.lyg-nav-btn.lyg-nav-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Mostra i bottoni solo su desktop (>= 1024px) */
@media (min-width: 1024px) {
    .lyg-nav-btn {
        display: flex !important;
    }
}

/* ===========================
   Swiper Slider Container
   =========================== */
.lyg-categories-wrapper .swiper {
    width: 100%;
    flex: 1 1 auto;
    /* Occupa tutto lo spazio tra i due bottoni */
    min-width: 0;
    /* Previene overflow nel flexbox */
    padding: 8px 0 40px;
    position: relative;
    /* overflow visible per non tagliare l'anello della categoria attiva */
    overflow: visible;
    touch-action: pan-y pinch-zoom;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.lyg-categories-wrapper .swiper-wrapper {
    display: flex;
    align-items: flex-start;
    touch-action: pan-x;
}

.lyg-categories-wrapper .swiper-slide {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: auto;
    /* Padding per dare spazio all'anello attivo senza essere tagliato */
    padding: 4px 2px;
}

/* ===========================
   Category Item
   =========================== */
.lyg-category-item {
    text-align: center;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Ensure consistent height for alignment */
}

.lyg-category-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    width: 100%;
}

.lyg-category-link:hover .lyg-category-item {
    transform: translateY(-5px);
}

.lyg-category-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 4px;
    border-radius: 50%;
}

/* ===========================
   Category Image
   =========================== */
.lyg-category-image-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
    position: relative;
    overflow: visible !important;
    border-radius: 50%;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
    padding: 3px !important;
    transition: all 0.3s ease;
    border: none !important;
}

.lyg-category-image-wrapper::before {
    content: '';
    position: absolute;
    inset: 3px;
    background: #fff;
    border-radius: 50%;
    z-index: 1;
    overflow: hidden;
}

.lyg-category-link:hover .lyg-category-image-wrapper {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none !important;
}

.lyg-category-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    position: relative;
    z-index: 2;
    transition: transform 0.3s ease;
    display: block;
}

.lyg-category-link:hover .lyg-category-image {
    transform: scale(1.05);
}

/* ===========================
   Category Name
   =========================== */
.lyg-category-name {
    font-size: 11px;
    font-weight: 500;
    color: #000;
    margin: 0;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
    transition: color 0.3s ease;
    max-width: 100px;
    margin: 0 auto;
    word-wrap: break-word;
    /* Fixed height for text area to ensure alignment */
    min-height: 32px;
    /* Altezza fissa per 2 righe di testo */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    text-align: center;
}

.lyg-category-link:hover .lyg-category-name {
    color: #007cba;
}

/* Categoria attiva/selezionata */
.lyg-category-link.is-active .lyg-category-name {
    color: #bc1888;
    font-weight: 700;
}

.lyg-category-link.is-active .lyg-category-image-wrapper {
    background: linear-gradient(45deg, #bc1888 0%, #cc2366 50%, #dc2743 100%) !important;
    box-shadow: 0 0 0 2px rgba(188, 24, 136, 0.35);
    border-radius: 50% !important;
}

/* ===========================
   Navigation Arrows
   =========================== */
.lyg-categories-wrapper .swiper-button-prev,
.lyg-categories-wrapper .swiper-button-next {
    width: 40px;
    height: 40px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 50%;
    color: #333;
    transition: all 0.3s ease;
}

.lyg-categories-wrapper .swiper-button-prev:after,
.lyg-categories-wrapper .swiper-button-next:after {
    font-size: 16px;
    font-weight: bold;
}

.lyg-categories-wrapper .swiper-button-prev:hover,
.lyg-categories-wrapper .swiper-button-next:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

.lyg-categories-wrapper .swiper-button-prev.swiper-button-disabled,
.lyg-categories-wrapper .swiper-button-next.swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.lyg-categories-wrapper .swiper-button-prev:focus,
.lyg-categories-wrapper .swiper-button-next:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* ===========================
   Pagination Dots
   =========================== */
.lyg-categories-wrapper .swiper-pagination {
    display: none !important;
    /* Hidden for Instagram-style scroll */
}

.lyg-categories-wrapper .swiper-pagination-bullet {
    display: none !important;
}

.lyg-categories-wrapper .swiper-pagination-bullet-active {
    display: none !important;
}

/* ===========================
   Navigation Arrows - Hidden
   =========================== */
.lyg-categories-wrapper .swiper-button-prev,
.lyg-categories-wrapper .swiper-button-next {
    display: none !important;
    /* Hidden for free scroll */
}

/* ===========================
   Swiper Slide Width
   =========================== */
.lyg-categories-wrapper .swiper-slide {
    width: auto !important;
    /* Auto width for free scrolling */
    align-items: flex-start !important;
    /* Align all items to the top */
}

/* ===========================
   Empty State
   =========================== */
.lyg-categories-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

/* ===========================
   RESPONSIVE MEDIA QUERIES
   =========================== */

/* Desktop: 1024px and above - Show 9 categories */
@media (min-width: 1024px) {
    .lyg-category-image-wrapper {
        width: 80px;
        height: 80px;
        padding: 3px;
    }

    .lyg-category-image-wrapper::before {
        inset: 3px;
    }

    .lyg-category-name {
        font-size: 11px;
    }
}

/* Tablet: 768px to 1023px - Show 5 categories */
@media (min-width: 768px) and (max-width: 1023px) {
    .lyg-categories-wrapper {
        max-width: 900px;
    }

    .lyg-category-image-wrapper {
        width: 90px;
        height: 90px;
        padding: 0px;
    }

    .lyg-category-image-wrapper::before {
        inset: 3px;
    }

    .lyg-category-name {
        font-size: 12px;
    }

    .lyg-categories-wrapper .swiper-button-prev,
    .lyg-categories-wrapper .swiper-button-next {
        width: 35px;
        height: 35px;
    }

    .lyg-categories-wrapper .swiper-button-prev:after,
    .lyg-categories-wrapper .swiper-button-next:after {
        font-size: 14px;
    }
}

/* Mobile: up to 767px - Show 3 categories */
@media (max-width: 767px) {
    .lyg-categories-wrapper {
        padding: 0px;
    }

    .lyg-categories-wrapper .swiper {
        padding: 0px;
    }

    .lyg-category-image-wrapper {
        width: 70px;
        height: 70px;
        padding: 3px;
    }

    .lyg-category-image-wrapper::before {
        inset: 3px;
    }

    .lyg-category-name {
        font-size: 10px;
        max-width: 80px;
    }

    .lyg-categories-wrapper .swiper-button-prev,
    .lyg-categories-wrapper .swiper-button-next {
        width: 30px;
        height: 30px;
    }

    .lyg-categories-wrapper .swiper-button-prev:after,
    .lyg-categories-wrapper .swiper-button-next:after {
        font-size: 12px;
    }

    .lyg-categories-wrapper .swiper-pagination-bullet {
        width: 8px;
        height: 8px;
    }

    .lyg-categories-wrapper .swiper-pagination-bullet-active {
        width: 20px;
    }
}

/* Extra small mobile: up to 480px */
@media (max-width: 480px) {
    .lyg-categories-wrapper .swiper {
        padding: 0px;
    }

    .lyg-category-image-wrapper {
        width: 60px;
        height: 60px;
        padding: 2px;
    }

    .lyg-category-image-wrapper::before {
        inset: 2px;
    }

    .lyg-category-name {
        font-size: 9px;
        max-width: 70px;
    }

    .lyg-categories-wrapper .swiper-button-prev,
    .lyg-categories-wrapper .swiper-button-next {
        width: 28px;
        height: 28px;
    }
}

/* ===========================
   Accessibility Improvements
   =========================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .lyg-category-image-wrapper {
        border-width: 4px;
    }

    .lyg-categories-wrapper .swiper-button-prev,
    .lyg-categories-wrapper .swiper-button-next {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .lyg-category-item,
    .lyg-category-link,
    .lyg-category-image-wrapper,
    .lyg-category-image,
    .lyg-category-name,
    .lyg-categories-wrapper .swiper-button-prev,
    .lyg-categories-wrapper .swiper-button-next,
    .lyg-categories-wrapper .swiper-pagination-bullet {
        transition: none;
    }
}

/* Focus visible for better keyboard navigation */
.lyg-category-link:focus-visible {
    outline: 3px solid #007cba;
    outline-offset: 5px;
}