/**
 * Alabastro Finiture - Frontend Styles
 * Mantiene compatibilità con lo stile originale di Elementor
 */

/* ========================================
   Wrapper Principale - CSS Grid
======================================== */

.alabastro-finiture-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    width: 100%;
}

/* Singola categoria = 1 colonna */
.alabastro-finiture-wrapper:has(> .e-con:only-child) {
    grid-template-columns: 1fr;
}

/* Colonna per categoria (stile Elementor) */
.alabastro-finiture-wrapper>.e-con {
    width: 100%;
}

/* ========================================
   Contenitore Finiture (stile originale)
======================================== */

.finiture-container-v2 {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
}

/* Nowrap solo quando c'è una sola categoria */
.alabastro-finiture-wrapper:has(> .e-con:only-child) .finiture-container-v2 {
    flex-wrap: nowrap;
    overflow-x: auto;
}

/* ========================================
   Singolo Item Finitura
======================================== */

.finitura-item-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    transition: all 0.3s ease;
}

/* Cerchio immagine */
.finitura-image-circle {
    position: relative;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    overflow: hidden;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.finitura-image-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Didascalia */
.finitura-caption {
    font-family: 'Albert Sans', sans-serif;
    font-size: 14px;
    line-height: 1.2;
    text-align: center;
    color: #333;
    word-wrap: break-word;
}

/* ========================================
   Stato ATTIVO (disponibile)
======================================== */

.finitura-wrapper-active {
    cursor: pointer;
}

.finitura-wrapper-active:hover .finitura-image-circle {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Stato DISABILITATO (non disponibile)
   Mantenuto per retrocompatibilità con vecchio shortcode
======================================== */

.finitura-wrapper-disabled {
    cursor: not-allowed;
}

.finitura-wrapper-disabled .finitura-image-circle,
.finitura-wrapper-disabled .finitura-caption {
    opacity: 0.5;
}

.finitura-wrapper-disabled .finitura-image-circle img {
    filter: grayscale(100%) brightness(0.8);
}

.finitura-wrapper-disabled .finitura-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
}

/* X bianca per indicare non disponibile */
.finitura-wrapper-disabled .finitura-image-circle::after {
    content: '\2715';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

/* ========================================
   Titoli Categoria (stile Elementor)
======================================== */

.alabastro-finiture-wrapper .elementor-heading-title {
    font-size: 1.2em;
    margin-bottom: 15px;
    text-align: center;
    color: #333;
}

/* ========================================
   Responsive - Tablet
======================================== */

@media screen and (max-width: 991px) {
    .alabastro-finiture-wrapper {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .finiture-container-v2 {
        flex-wrap: wrap;
        gap: 15px;
        overflow-x: visible;
    }

    .finitura-item-wrapper {
        width: 75px;
    }

    .finitura-image-circle {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   Responsive - Mobile Large
======================================== */

@media screen and (max-width: 768px) {
    .alabastro-finiture-wrapper {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .alabastro-finiture-wrapper:has(> .e-con:only-child) {
        max-width: none;
    }

    .elementor-element.elementor-element-finiture.e-flex.e-con-boxed.e-con.e-child {
        padding: 1rem;
    }

    .finiture-container-v2 {
        flex-wrap: wrap;
        gap: 12px;
        overflow-x: visible;
    }

    .finitura-item-wrapper {
        width: 70px;
    }

    .finitura-image-circle {
        width: 55px;
        height: 55px;
        margin-bottom: 8px;
    }

    .finitura-caption {
        font-size: 13px;
    }
}

/* ========================================
   Responsive - Mobile Small
======================================== */

@media screen and (max-width: 480px) {
    .alabastro-finiture-wrapper {
        gap: 20px;
    }

    .finiture-container-v2 {
        gap: 10px;
    }

    .finitura-item-wrapper {
        width: 60px;
    }

    .finitura-image-circle {
        width: 45px;
        height: 45px;
        margin-bottom: 6px;
    }

    .finitura-caption {
        font-size: 12px;
    }

    .finitura-wrapper-disabled .finitura-image-circle::after {
        font-size: 18px;
    }

    .alabastro-finiture-wrapper .elementor-heading-title {
        font-size: 1.1em;
        margin-bottom: 12px;
    }
}

/* ========================================
   Responsive - Mobile Extra Small
======================================== */

@media screen and (max-width: 360px) {
    .finitura-item-wrapper {
        width: 55px;
    }

    .finitura-image-circle {
        width: 40px;
        height: 40px;
    }

    .finitura-caption {
        font-size: 11px;
    }
}

/* ========================================
   Transizioni
======================================== */

.finitura-item-wrapper,
.finitura-image-circle {
    transition: all 0.3s ease;
}

/* ========================================
   Print Styles
======================================== */

@media print {
    .alabastro-finiture-wrapper {
        display: block;
    }

    .finitura-image-circle {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .finitura-wrapper-active:hover .finitura-image-circle {
        transform: none;
        box-shadow: none;
    }
}

/* ========================================
   Fallback per browser senza :has()
======================================== */

@supports not selector(:has(*)) {
    .alabastro-finiture-wrapper {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .alabastro-finiture-wrapper>.e-con {
        flex: 1 1 280px;
        max-width: 500px;
    }
}

/* ========================================
   Lightbox
======================================== */

.alabastro-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alabastro-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.alabastro-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.alabastro-lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 8px;
    transform: scale(0.9);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Spinner di caricamento */
.alabastro-lightbox-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: alabastro-spin 0.8s linear infinite;
}

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

.alabastro-lightbox-overlay.active .alabastro-lightbox-image {
    transform: scale(1);
}

.alabastro-lightbox-caption {
    color: #fff;
    font-size: 18px;
    margin-top: 15px;
    text-align: center;
    font-family: 'Albert Sans', sans-serif;
}

.alabastro-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.alabastro-lightbox-close:hover {
    color: #ccc;
    transform: scale(1.1);
}

@media screen and (max-width: 768px) {
    .alabastro-lightbox-close {
        top: 15px;
        right: 15px;
        font-size: 28px;
    }

    .alabastro-lightbox-caption {
        font-size: 16px;
        padding: 0 20px;
    }
}