/* =========================================================================
 * iCONsite — Module: single-video-youtube
 * Sezioni: FRONTEND (grid + lightbox) e ADMIN (editor pannello).
 * Convenzione classi: .svyt-* (admin) | .module-svyt / .svyt-* (frontend).
 * Zero dipendenze cross-modulo.
 * ========================================================================= */


/* =========================================================================
 * === FRONTEND ============================================================
 * ========================================================================= */

.svyt-lang-tabs.icns-lang-tabs {
    padding: 0 0px;
    margin-bottom: 3px;
}

/* Config grid: dimensioni thumbnail e gap, sovrascrivibili dal tema. */
.module-svyt {
    --svyt-thumb-width: 280px;
    --svyt-thumb-aspect: 16 / 9;
    --svyt-gap: 16px;
}

.module-svyt {
    width: 100%;
    background: var(--module-bg);
    box-shadow: var(--module-surface-shadow);
    border-radius: var(--radius);
    backdrop-filter: blur(5px);
}
.module-svyt--no-bg {
    background: transparent;
    padding: 20px 0;
    backdrop-filter: blur(0px);
    box-shadow: none;
}

.module-svyt-title {
    margin: 1rem 0 1.5rem;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-h);   /* CARTA: TITOLI */
}

.module-svyt .svyt-empty {
    text-align: center;
    color: var(--text-p);   /* CARTA: PARAGRAFI, attenuato */
    opacity: .75;
    margin: 1rem 0;
    font-style: italic;
}

.module-svyt .svyt-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, var(--svyt-thumb-width));
    justify-content: center;
    gap: var(--svyt-gap);
}

/* SINGLE MODE — un solo video, centrato e più grande del thumb di galleria.
   Non più grid, ma flex centrato; il video occupa lo spazio "naturale". */
.module-svyt--single .svyt-grid {
    display: block;
    width: 100%;
    max-width: 1000px; /* fallback (2/9): il valore reale e' inline dal frontend */
    margin: 0 auto;
}
.module-svyt--single .svyt-item {
    width: 100%;
}
.module-svyt--single .svyt-thumb {
    aspect-ratio: 16 / 9;
}

.module-svyt .svyt-item {
    margin: 0;
    display: flex;
    flex-direction: column;
}

.module-svyt .svyt-item-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: inherit;
    text-align: left;
    font: inherit;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.module-svyt .svyt-thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: var(--svyt-thumb-aspect);
    border-radius: var(--radius-inner);
    overflow: hidden;
    background: #000;
    transition: transform 0.15s;
}
.module-svyt .svyt-item-trigger:hover .svyt-thumb {
    transform: translateY(0px);
}
.module-svyt .svyt-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.module-svyt .svyt-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.15s, transform 0.15s;
}
.module-svyt .svyt-item-trigger:hover .svyt-thumb-play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.module-svyt .svyt-caption {
    color: var(--text-p);   /* CARTA: PARAGRAFI */
    font-size: 13px;
    line-height: 1.3;
    padding: 0 4px;
    text-align: center;
    margin-top: 5px;
}


/* =========================================================================
 * LIGHTBOX (autocontained, dedicato a questo modulo)
 * ========================================================================= */

.svyt-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 32px;
    box-sizing: border-box;
}
.svyt-lightbox.is-open {
    display: flex;
}

body.svyt-lightbox-open {
    overflow: hidden;
}

.svyt-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 48px;
    line-height: 1;
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.svyt-lightbox-close:hover {
    /* Lightbox = mondo neutro (17/8): nessun colore di brand sui controlli,
       il rollover e' intensita', non tinta. La X bianca si attenua. */
    opacity: 0.6;
}

.svyt-lightbox-prev,
.svyt-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.2s ease;
}
.svyt-lightbox-prev:hover,
.svyt-lightbox-next:hover {
    /* Mondo neutro: piu' presenza dello stesso neutro, nessuna tinta. */
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}
.svyt-lightbox-prev { left: 24px; }
.svyt-lightbox-next { right: 24px; }

.svyt-lightbox-stage {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.svyt-lightbox-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
}
.svyt-lightbox-player iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.svyt-lightbox-info {
    color: #fff;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}
.svyt-lightbox-title {
    color: #fff !important;
    margin: 0 0 8px;
    font-size: 16px !important;
    letter-spacing: 1px;
    text-transform: none;
    font-weight: 400;
}
.svyt-lightbox-descr {
    margin: 0;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 700px) {
    .svyt-lightbox {
        padding: 16px;
    }
    .svyt-lightbox-prev,
    .svyt-lightbox-next {
        width: 44px;
        height: 44px;
    }
    .svyt-lightbox-prev { left: 8px; }
    .svyt-lightbox-next { right: 8px; }
    .svyt-lightbox-close {
        top: 8px;
        right: 8px;
    }
}


/* =========================================================================
 * === ADMIN — pannello editor ============================================
 * ========================================================================= */

.svyt-panel {
    display: flex;
    flex-direction: column;
}

/* Riga superiore: tab IT/EN + toggle SFONDO */
.svyt-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0px 6px 0 8px;
}

/* Tab IT/EN: vestite dalla LEGGE UNICA del core (campagna 4/9).
   Le classi .svyt-lang-tab* restano ganci JS: zero regole visive. */

/* Riga aggiungi video */
.svyt-add-row {
    display: flex;
    gap: 8px;
    padding: 7px 7px 7px 8px;
    align-items: center;
    background: white;
    filter: drop-shadow(0px 5px 5px rgba(0, 0, 0, 0.07));
    border-radius: 0 8px 8px 0;
}
.svyt-add-input {
    flex: 1;
    background: #fff;
    border: 1.5px solid var(--admin-green, #17d426);
    color: inherit;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    min-width: 0;
    max-height: 27px;
}
.svyt-add-input:focus {
    outline: none;
    border-color: var(--primary);
}
.svyt-add-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    max-width: 160px;
    height: 26px;
    
}

/* Empty state */
.svyt-panel .svyt-no-items {
    margin: 8px 0 8px 8px;
    padding: 14px 16px;
    background: transparent;
    border: 1px dashed #c0c0c0;
    border-radius: 3px 8px 3px 6px;
    color: #777;
    text-align: center;
    font-size: 0.75rem;
}

/* Lista video */
.svyt-panel .svyt-items-list {
    list-style: none;
    margin: 0;
    padding: 0 0 15px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
    border-top: 0px solid #ededed;
    max-height: 60vh;
    overflow-y: auto;
}

.svyt-panel .svyt-item {
    padding: 14px 16px 11px 14px;
    position: relative;
    border-bottom: solid 1px #e7e7e7;
    margin-bottom: -17px;
}

/* Azioni a destra, in colonna */
.svyt-panel .svyt-item-actions {
    position: absolute;
    top: 12px;
    right: 7px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
    opacity: 0.2;
    filter: saturate(0);
    transition: all 0.5s ease;
}

.module-card:hover .svyt-panel .svyt-item-actions {
    opacity: 1;
    filter: saturate(1);
}

.svyt-panel .svyt-item-action-btn {
    padding: 5px !important;
    width: 30px;
    height: 18px;
    background: white;
    border: 1.5px solid var(--gallery-move-arrow);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    transition: all 200ms ease-out;
}

.svyt-panel .svyt-item-action-btn svg {
    width: 12px;
    height: 12px;
}

.svyt-panel .svyt-item-action-btn:hover:not([disabled]) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.svyt-panel .svyt-item-action-btn[disabled] {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.svyt-panel .svyt-item-action-btn--danger:not([disabled]) {
    color: white;
    background: red;
    border: 1.5px solid transparent;
    margin: 2px 0px 5px 0;
}
.svyt-panel .svyt-item-action-btn--danger:hover:not([disabled]) {
    filter: brightness(1.2);
    background: red;
    border-color: red;
}

/* Body item: thumb + fields si adattano orizzontalmente,
   padding-right lascia spazio per le actions verticali senza sovrapposizione */
.svyt-panel .svyt-item-body {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
    padding-right: 36px;
}

@media (max-width: 700px) {
    .svyt-panel .svyt-item-body {
        grid-template-columns: 1fr;
        padding-right: 48px;
    }
}

.svyt-panel .svyt-item-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}
.svyt-panel .svyt-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
/* Play overlay sull'anteprima admin */
.svyt-panel .svyt-item-thumb::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.svyt-panel .svyt-item-thumb:hover::after {
    opacity: 1;
}

.svyt-panel .svyt-item-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.svyt-panel .svyt-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thumb-and-id {
    display: flex;
    gap: 8px;
    flex-direction: column;
}

.svyt-panel .svyt-field.id-under-thumb {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.svyt-panel .svyt-field-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #222222;
    font-weight: 800;
}

.svyt-panel .svyt-input {
    background: #fff;
    border: 1px solid #e4e4e4;
    color: inherit;
    padding: 8px 10px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
    max-height: 28px;
}
.svyt-panel .svyt-input:hover {
    border-color: #c0c0c0;
}


.svyt-panel .svyt-input:focus, .svyt-panel .svyt-input--textarea:focus {
    outline: none;
    border-color: var(--primary) !important;
}
.svyt-panel .svyt-input--textarea {
    min-height: 77px;
    resize: vertical;
    line-height: 1.5;
    border: 1px solid #e4e4e4;
}
.svyt-panel .svyt-input--textarea:hover {
    border-color: #d3d3d3;
}

.svyt-panel .svyt-lang-pane {
    display: none;
}
.svyt-panel .svyt-lang-pane.is-active {
    display: block;
}

input:disabled {
    opacity: 0.4;
    filter: saturate(0);
    border-color: #d5d5d5;
}

/* ---- LARGHEZZA (2/9): tendina px nella riga superiore, DOPO Sfondo —
   CLONE di .cta-layout* (a sua volta clone .pg-layout*), classi proprie.
   Impostazione delle gallerie: la top-row era space-between con DUE figli
   (tab | Sfondo); col terzo figlio lo space-between sparava Sfondo al
   centro. margin-left:auto su Sfondo: tab a sinistra, Sfondo spinto a
   destra, tendina subito dopo. ---- */
.svyt-top-row .icns-editor-bg-switch {
    margin-left: auto;
}
.svyt-layout {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
    margin: 0 1px 6px 0;
}
.svyt-layout-sel {
    width: 84px;   /* "1200px" deve starci per intero */
}
.svyt-layout-sel .icns-sel-trigger {
    width: 100%;
    min-width: 0;
    padding: 0.35rem 0.3rem 0.35rem 0.55rem;
    font-size: 0.72rem;
    max-height: 26px;
}
.svyt-layout-sel .icns-sel-value {
    overflow: hidden;
    white-space: nowrap;
}
