/* =====================================================
   PLAYER v9 — Fix spazio bianco mobile + ottimizzazioni
   ===================================================== */

/* ── DESKTOP ── */
.jc-corso-player { width: 100%; }

.jc-player-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    width: 100%;
    min-height: calc(100vh - 80px);
}

.jc-player-sidebar {
    width: 340px; min-width: 340px; max-width: 340px;
    height: calc(100vh - 80px);
    overflow-y: auto; overflow-x: hidden;
    border-right: 1px solid #eee;
    background: #fff; flex-shrink: 0;
}

.jc-player-main {
    flex: 1; min-width: 0; padding: 24px 32px;
}

.jc-sidebar-header { padding: 16px; border-bottom: 1px solid #f0f0f0; }
.jc-sidebar-header h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; line-height: 1.4; color: #222; }
.jc-sidebar-progress { margin-top: 6px; }
.jc-progress-bar-track { background: #eee; border-radius: 99px; height: 6px; overflow: hidden; margin-bottom: 4px; }
.jc-progress-bar-fill { background: linear-gradient(90deg,#d4637a,#e8a0b0); height: 100%; border-radius: 99px; transition: width .5s ease; }
.jc-progress-label { font-size: 11px; color: #aaa; }

.jc-modulo-nav-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; text-decoration: none; color: inherit;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s; cursor: pointer;
}
.jc-modulo-nav-item:hover { background: rgba(212,99,122,.05); }
.jc-modulo-nav-item.active { background: rgba(212,99,122,.07); border-left-color: #d4637a; }

.jc-nav-checkbox {
    width: 18px; height: 18px; flex-shrink: 0; margin-top: 3px;
    border: 2px solid #ccc; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s, border-color .15s; background: #fff;
}
.jc-nav-checkbox:hover { border-color: #d4637a; background: rgba(212,99,122,.06); }
.jc-nav-checkbox.checked { background: #d4637a; border-color: #d4637a; }

.jc-nav-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.jc-nav-number { font-size: 10px; font-weight: 700; color: #bbb; text-transform: uppercase; letter-spacing: .4px; }
.jc-nav-title { font-size: 13px; font-weight: 500; color: #333; line-height: 1.45; white-space: normal; word-break: break-word; }
.jc-modulo-nav-item.active .jc-nav-title { color: #d4637a; font-weight: 600; }
.jc-modulo-nav-item.completed .jc-nav-title { text-decoration: line-through; color: #aaa; }
.jc-nav-durata { font-size: 11px; color: #bbb; white-space: nowrap; flex-shrink: 0; margin-top: 3px; }

.jc-sidebar-allegati { padding: 12px 14px; border-top: 1px solid #f0f0f0; }
.jc-sidebar-allegati h4 { font-size: 12px; color: #aaa; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 8px; }
.jc-allegato-link { display: block; font-size: 13px; color: #555; text-decoration: none; padding: 4px 0; }
.jc-allegato-link:hover { color: #d4637a; }
.jc-sidebar-footer { padding: 12px 14px; border-top: 1px solid #f0f0f0; }

/* Video container con loading indicator */
.jc-video-container { width: 100%; margin-bottom: 20px; position: relative; }
.jc-video-player { width: 100%; max-height: 60vh; background: #000; display: block; border-radius: 8px; }

/* Loading spinner sul video */
.jc-video-loading {
    position: absolute; inset: 0;
    background: #000; border-radius: 8px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; color: #fff;
    transition: opacity .3s;
}
.jc-video-loading.hidden { opacity: 0; pointer-events: none; }
.jc-video-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.2);
    border-top-color: #d4637a;
    border-radius: 50%;
    animation: jcSpin .8s linear infinite;
}
@keyframes jcSpin { to { transform: rotate(360deg); } }
.jc-video-loading span { font-size: 13px; color: rgba(255,255,255,.7); }

/* Buffer progress bar sotto il video */
.jc-video-buffer-bar {
    height: 3px; background: #f0f0f0; border-radius: 99px;
    overflow: hidden; margin-bottom: 16px; margin-top: -14px;
}
.jc-video-buffer-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4637a 0%, #e8a0b0 50%, #d4637a 100%);
    background-size: 200% 100%;
    border-radius: 99px;
    transition: width .3s ease;
}
.jc-video-buffer-fill.buffering {
    animation: jcBufferSlide 1.5s linear infinite;
}
@keyframes jcBufferSlide {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.jc-lesson-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; color: #222; line-height: 1.3; }
.jc-lesson-description { font-size: 15px; color: #555; margin: 0 0 16px; line-height: 1.6; }
.jc-lesson-navigation { display: flex; align-items: center; justify-content: space-between; margin-top: 24px; gap: 12px; }

/* Programma preview */
.jc-modulo-preview-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #f0f0f0; transition: background .12s; }
.jc-modulo-preview-item:last-child { border-bottom: none; }
.jc-modulo-preview-item.jc-clickable { cursor: pointer; }
.jc-modulo-preview-item.jc-clickable:hover { background: #fdf9fb; }
.jc-modulo-preview-number { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: #f0f0f0; color: #666; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.jc-modulo-preview-item.jc-free .jc-modulo-preview-number { background: #fdf2f5; color: #d4637a; }
.jc-modulo-preview-info { flex: 1; min-width: 0; }
.jc-modulo-preview-title { display: block; font-size: 14px; font-weight: 600; color: #222; margin-bottom: 3px; }
.jc-modulo-preview-desc  { display: block; font-size: 13px; color: #888; line-height: 1.4; }
.jc-modulo-preview-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.jc-modulo-preview-durata { font-size: 12px; color: #aaa; }
.jc-play-badge { background: #fdf2f5; color: #d4637a; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }

.jc-btn-toggle-complete { transition: all .2s; }
.jc-btn-success { background: #2ecc71 !important; color: #fff !important; border-color: #2ecc71 !important; }
.jc-btn-success:hover { background: #e74c3c !important; border-color: #e74c3c !important; }

/* ── MOBILE ── */
@media (max-width: 860px) {

    /* ⚠️ FIX SPAZIO BIANCO: player desktop completamente collassato */
    .jc-corso-player {
        display: none !important;
        height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Mobile player visibile */
    .jc-mobile-player { display: block; }

    .jc-mob-header {
        padding: 16px; background: #fff;
        border-bottom: 1px solid #f0f0f0;
        position: sticky; top: 0; z-index: 100;
    }
    .jc-mob-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
    .jc-mob-header-top h2 { font-size: 15px; font-weight: 700; margin: 0; color: #222; flex: 1; line-height: 1.3; }
    .jc-mob-back { font-size: 13px; color: #d4637a; text-decoration: none; font-weight: 600; white-space: nowrap; margin-left: 10px; }
    .jc-mob-progress-track { background: #f0f0f0; border-radius: 99px; height: 6px; overflow: hidden; }
    .jc-mob-progress-fill { background: linear-gradient(90deg,#d4637a,#e8a0b0); height: 100%; border-radius: 99px; transition: width .5s; }
    .jc-mob-progress-txt { font-size: 11px; color: #aaa; margin-top: 4px; }

    .jc-mob-lessons { background: #fff; }
    .jc-mob-lesson-item {
        display: flex; align-items: center; gap: 12px;
        padding: 14px 16px; border-bottom: 1px solid #f5f5f5;
        cursor: pointer; transition: background .12s;
        -webkit-tap-highlight-color: transparent;
    }
    .jc-mob-lesson-item:active { background: #fdf2f5; }
    .jc-mob-lesson-item.mob-active { background: #fdf2f5; }

    .jc-mob-checkbox {
        width: 22px; height: 22px; flex-shrink: 0;
        border: 2px solid #ddd; border-radius: 5px;
        display: flex; align-items: center; justify-content: center;
        background: #fff; transition: background .15s, border-color .15s;
    }
    .jc-mob-checkbox.checked { background: #d4637a; border-color: #d4637a; }

    .jc-mob-lesson-info { flex: 1; min-width: 0; }
    .jc-mob-lesson-num { font-size: 10px; font-weight: 700; color: #bbb; text-transform: uppercase; letter-spacing: .4px; display: block; margin-bottom: 2px; }
    .jc-mob-lesson-title { font-size: 14px; font-weight: 500; color: #333; line-height: 1.4; white-space: normal; word-break: break-word; }
    .jc-mob-lesson-item.mob-active .jc-mob-lesson-title { color: #d4637a; font-weight: 600; }
    .jc-mob-lesson-item.mob-completed .jc-mob-lesson-title { color: #bbb; text-decoration: line-through; }

    .jc-mob-lesson-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
    .jc-mob-lesson-dur { font-size: 11px; color: #bbb; white-space: nowrap; }
    .jc-mob-lesson-play { width: 32px; height: 32px; border-radius: 50%; background: #d4637a; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
    .jc-mob-lesson-play svg { margin-left: 2px; }

    .jc-mob-allegati { padding: 16px; border-top: 2px solid #f0f0f0; background: #fafafa; }
    .jc-mob-allegati h4 { font-size: 12px; color: #aaa; text-transform: uppercase; letter-spacing: .5px; margin: 0 0 10px; }
    .jc-mob-allegati a { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border-radius: 8px; border: 1px solid #eee; margin-bottom: 8px; font-size: 13px; color: #444; text-decoration: none; }
    .jc-mob-allegati a:last-child { margin-bottom: 0; }
    .jc-mob-allegati a:hover { border-color: #d4637a; color: #d4637a; }

    .jc-mob-video-drawer {
        position: fixed; bottom: 0; left: 0; right: 0;
        background: #fff; border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 40px rgba(0,0,0,.18);
        z-index: 99998; transform: translateY(100%);
        transition: transform .35s cubic-bezier(0.34,1.1,0.64,1);
        max-height: 95vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .jc-mob-video-drawer.mob-drawer-open { transform: translateY(0); }

    .jc-mob-drawer-handle { display: flex; justify-content: center; padding: 12px 0 4px; cursor: pointer; }
    .jc-mob-drawer-handle span { width: 36px; height: 4px; background: #ddd; border-radius: 99px; display: block; }

    .jc-mob-drawer-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 16px 12px; border-bottom: 1px solid #f0f0f0; }
    .jc-mob-drawer-title { font-size: 15px; font-weight: 700; color: #222; line-height: 1.4; flex: 1; }
    .jc-mob-drawer-close { background: #f5f5f5; border: none; border-radius: 50%; width: 30px; height: 30px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #666; flex-shrink: 0; margin-left: 10px; }

    /* Video drawer con loading */
    .jc-mob-drawer-video { padding: 0; background: #000; position: relative; }
    .jc-mob-drawer-video video { width: 100%; max-height: 40vh; display: block; }

    /* Spinner mobile */
    .jc-mob-video-spinner {
        position: absolute; inset: 0;
        display: flex; align-items: center; justify-content: center;
        background: #000; transition: opacity .3s;
    }
    .jc-mob-video-spinner.hidden { opacity: 0; pointer-events: none; }
    .jc-mob-video-spinner div {
        width: 36px; height: 36px;
        border: 3px solid rgba(255,255,255,.2);
        border-top-color: #d4637a;
        border-radius: 50%;
        animation: jcSpin .8s linear infinite;
    }

    .jc-mob-drawer-content { padding: 16px; }
    .jc-mob-drawer-desc { font-size: 14px; color: #555; line-height: 1.6; margin: 0 0 16px; }

    .jc-mob-drawer-nav { display: flex; gap: 10px; margin-bottom: 16px; }
    .jc-mob-drawer-nav button { flex: 1; text-align: center; padding: 12px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: background .15s; }
    .jc-mob-nav-prev { background: #f5f5f5; color: #555; }
    .jc-mob-nav-next { background: #d4637a; color: #fff; }

    .jc-mob-complete-btn {
        width: 100%; padding: 14px; border-radius: 12px;
        font-size: 14px; font-weight: 600; cursor: pointer;
        border: 2px solid #d4637a; color: #d4637a; background: #fff;
        transition: all .15s; margin-bottom: 12px;
        display: flex; align-items: center; justify-content: center; gap: 8px;
    }
    .jc-mob-complete-btn.mob-completed { background: #2ecc71; border-color: #2ecc71; color: #fff; }
    .jc-mob-complete-btn.mob-completed:hover { background: #e74c3c; border-color: #e74c3c; }

    .jc-mob-form-section { background: #f9f4ff; border: 1px solid #e0d0f0; border-radius: 12px; padding: 16px; text-align: center; margin-top: 12px; }

    .jc-mob-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99997; opacity: 0; pointer-events: none; transition: opacity .3s; }
    .jc-mob-overlay.mob-overlay-show { opacity: 1; pointer-events: all; }
}

/* Desktop: nasconde elementi mobile */
@media (min-width: 861px) {
    .jc-mobile-player { display: none !important; }
    .jc-mob-video-drawer { display: none !important; }
    .jc-mob-overlay { display: none !important; }
}
