/* ============================================================
   1. GALLERIA EBOOK (PAGINA PRINCIPALE)
   ============================================================ */
.ebm-gallery-container { 
    width: 100%; 
    margin: 0 auto; 
}

.ebm-product-grid {
    display: grid !important;
    /* grid-template-columns: repeat(4, 1fr) !important; */
    grid-template-columns: repeat(5, 1fr) !important; 
    gap: 30px !important;
    padding: 20px 0 !important;
}

.ebm-card { text-align: center; }

.ebm-img-container {
    margin: 0 auto 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ebm-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ebm-card-image:hover { transform: scale(1.05); }

/* ============================================================
   2. PAGINA DETTAGLIO (LAYOUT 2 COLONNE)
   ============================================================ */
/* Forza il layout a due colonne */
.ebm-product-view {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 40px !important;
    width: 100% !important;
    margin: 0 auto;
}

/* Colonna Sinistra (1/3 di spazio) */
.ebm-view-left {
    flex: 0 0 33.333% !important;
    max-width: 33.333% !important;
}

/* Colonna Destra (2/3 di spazio) */
.ebm-view-right {
    flex: 0 0 66.666% !important;
    max-width: 66.666% !important;
    display: flex !important;
    flex-direction: column !important; /* Incolonna gli elementi interni */
    text-align: left !important;
}

/* Immagine responsive nella sua colonna */
.ebm-view-left img {
    width: 100% !important;
    height: auto !important;
}

/* Responsive per mobile */
@media (max-width: 768px) {
    .ebm-product-view {
        flex-direction: column !important;
    }
    .ebm-view-left, .ebm-view-right {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* --- COLONNA SINISTRA: COVER (Nessun taglio) --- */
.ebm-view-left .ebm-img-container {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
}


/* --- COLONNA DESTRA: TESTI E FORMATI --- */
.ebm-view-right {
    text-align: left !important;
}

/* Colonna Destra: Testi */
.ebm-view-right {
    text-align: left !important;
}

.ebm-view-title { 
    font-size: 2.8rem !important; 
    margin-bottom: 5px !important; 
    font-weight: 700;
}

.ebm-view-author { 
    font-size: 1.3rem; 
    margin-bottom: 15px; 
    color: #555; 
}

/* Stelle e Recensioni */
.ebm-view-rating-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.ebm-rating .dashicons {
    color: #ffb400;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.ebm-count-rev { color: #888; font-size: 0.9rem; }
.ebm-write-link { color: #007cba; text-decoration: underline; font-size: 0.9rem; }

.ebm-view-price {
    font-size: 2.2rem;
    font-weight: bold;
    color: #DEC19E;
    margin: 20px 0;
}

/* ============================================================
   3. BOX SELEZIONE FORMATI (MUTUAMENTE ESCLUSIVI)
   ============================================================ */

.ebm-format-selector {
    display: flex !important;
    flex-wrap: wrap !important; /* Permette agli elementi di andare a capo se non c'è spazio */
    gap: 10px !important;
    margin: 20px 0 !important;
}

.ebm-format-box {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 15px !important;
    border: 2px solid #eee !important; /* Bordo grigio chiaro di base */
    border-radius: 8px !important;
    background-color: #ffffff !important;
    cursor: pointer;
    transition: all 0.2s ease-in-out !important; /* Transizione fluida */
}

.ebm-format-box .dashicons {
    font-size: 20px !important; /* Dimensione icona pi첫 adatta per stare a lato */
    width: 20px !important;
    height: 20px !important;
    margin: 0 !important; /* Rimuove margini vecchi */
}

.ebm-format-label {
    margin: 0 !important;
    font-size: 13px !important;
    text-transform: uppercase;
    font-weight: 700;
}

/* Nascondi radio */
.ebm-format-box input[type="radio"] {
    display: none !important;
}

/* --- EFFETTO HOVER (Passaggio del mouse) --- */
/* Solo sui box che hanno la classe 'available' */
.ebm-format-box.available:hover {
    border-color: #007cba !important; /* Colore blu WordPress */
    background-color: #f9f9f9 !important;
    transform: translateY(-2px); /* Piccolo saltino verso l'alto */
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* --- STATO SELEZIONATO (Dopo il click) --- */
.ebm-format-box.selected {
    border-color: #007cba !important; /* Verde (o usa #007cba per il blu) */
    background-color: #f0fff4 !important; /* Sfondo verdino chiarissimo */
    box-shadow: inset 0 0 0 1px #DEC19E; /* Rinforza il bordo interno */
}

/* Cambio colore icona e testo quando selezionato */
.ebm-format-box.selected .dashicons,
.ebm-format-box.selected .ebm-format-label {
    color: #DEC19E !important;
    font-weight: bold;
}

/* --- STATO DISABILITATO --- */
.ebm-format-box:not(.available) {
    background-color: #f5f5f5 !important;
    border-color: #eee !important;
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* ============================================================
   4. DESCRIZIONE ESPANDIBILE CON SFUMATURA
   ============================================================ */
.ebm-description-wrapper {
    margin: 20px 0;
    position: relative;
}

/* --- DESCRIZIONE ESPANDIBILE --- */
.ebm-description-container {
    max-height: 150px; /* Se la descrizione è più corta di questo, non vedrai l'effetto */
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
    position: relative;
}

/* Quando clicchi "Leggi tutto" */
.ebm-description-container.expanded {
    max-height: 2500px !important; /* Valore molto alto per contenere tutto il testo */
}

/* Sfumatura (opzionale, utile per far capire che il testo continua) */
.ebm-description-container:not(.expanded)::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(transparent, white);
    pointer-events: none;
}

/* Pulsante */
.ebm-read-more-btn {
    display: inline-block;
    margin-top: 10px;
    color: #007cba;
    font-weight: bold;
    cursor: pointer;
    text-decoration: underline;
}

/* ============================================================
   5. BOTTONE DOWNLOAD (STILE ELEMENTOR RICHIESTO)
   ============================================================ */
.ebm-download-btn {
    padding: 12px 20px !important;
    font-family: var(--e-global-typography-accent-font-family, Sans-serif) !important;
    font-size: var(--e-global-typography-accent-font-size) !important;
    font-weight: var(--e-global-typography-accent-font-weight) !important;
    text-transform: var(--e-global-typography-accent-text-transform) !important;
    line-height: var(--e-global-typography-accent-line-height) !important;
    border-radius: 8px !important;
    background-color: #DEC19E !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer;
    display: block;
    width: fit-content;
}

.ebm-download-btn:hover { background-color: #B19A7E !important;}
.ebm-download-btn.disabled { background-color: #888 !important; cursor: not-allowed; }

/* ============================================================
   6. RESPONSIVE
   ============================================================ */
@media (max-width: 992px) {
    .ebm-product-view { flex-direction: column; align-items: center; }
    .ebm-view-left { flex: 0 0 auto !important; width: 300px; margin-bottom: 30px; }
    .ebm-view-right { text-align: center !important; }
    .ebm-view-rating-row { justify-content: center; }
    .ebm-download-btn { margin: 0 auto !important; }
    .ebm-product-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Stile per il pulsante disabilitato */
.ebm-download-btn.disabled {
    background-color: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}

/* Wrapper per il Tooltip */
.ebm-tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.ebm-tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%; /* Appare sopra il pulsante */
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    line-height: 1.4;
}

/* Freccetta del tooltip */
.ebm-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Mostra il tooltip al passaggio del mouse sul pulsante disabilitato */
.ebm-tooltip-wrapper:hover .ebm-tooltip-text {
    visibility: visible;
    opacity: 1;
}

#ebm-rating-range {
    -webkit-appearance: none;
    appearance: none;
    background: #eee; /* Colore del binario */
    height: 8px;
    border-radius: 5px;
    outline: none;
}

#ebm-rating-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #000;
    border-radius: 50%;
    cursor: pointer;
}

/* --- NUOVO EFFETTO 3D E ZOOM OUT 1.05 --- */

.ebm-img-wrapper, 
.ebm-view-left .ebm-img-container {
    overflow: hidden !important;
    line-height: 0;
    border: 1px solid #eee !important;
    border-radius: 0 !important; /* Bordi netti 3D */
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    background: #fff;
}

/* Immagine parte leggermente zoomata */
.ebm-img-wrapper img, 
.ebm-view-left .ebm-img-container img {
    width: 100% !important;
    display: block;
    transition: transform 0.6s ease !important;
    transform: scale(1.05) !important; 
    border-radius: 0 !important;
}

/* Hover: Cornice sale, Immagine torna a 1 (Zoom Out) */
.ebm-product-item:hover .ebm-img-wrapper,
.ebm-view-left .ebm-img-container:hover {
    transform: translateY(-8px) !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.25) !important;
}

.ebm-product-item:hover .ebm-img-wrapper img,
.ebm-view-left .ebm-img-container:hover img {
    transform: scale(1) !important; 
}

/* --- LOGICA TESTI GALLERIA --- */
.ebm-grid-title {
    text-transform: uppercase;
    font-weight: bold;
    margin-top: 25px; 
    margin-bottom: 5px;
    font-size: 1.05em;
    color: #000;
    line-height: 1.2;
    display: block;
}

/* Correzione Responsive estrema */
@media (max-width: 768px) {
    .ebm-product-view {
        display: block !important; /* Rompe il flex row */
    }
    
    .ebm-view-left, .ebm-view-right {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        display: block !important;
    }

    .ebm-view-right {
        text-align: center !important;
        margin-top: 30px;
    }

    .ebm-format-selector {
        justify-content: center !important;
    }

    /* Rende il player leggibile su mobile */
    .ebm-audio-player-wrapper {
        padding: 15px !important;
        margin: 20px 0 !important;
    }
}