/**
 * Lesson Styles - Course Lessons Layout and Design
 */

/* Container principale */
.lesson-container {
    display: flex;
    flex-wrap: wrap;
    margin: 2rem auto;
    max-width: 1200px;
    gap: 2rem;
}

/* Sidebar delle lezioni */
.lesson-sidebar {
    flex: 0 0 300px;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Contenuto principale della lezione */
.lesson-content {
    flex: 1;
    min-width: 0; /* Necessario per evitare overflow su flex items */
}

/* Informazioni sul corso nella sidebar */
.course-info {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.course-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.course-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

.course-title a:hover {
    color: #0073aa;
}

.course-thumbnail {
    margin-bottom: 1rem;
}

.course-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Lista delle lezioni nella sidebar */
.lessons-list h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #333;
}

.lesson-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lesson-menu li {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

.lesson-menu li:hover {
    background-color: #e9ecef;
}

.lesson-menu li.current-lesson {
    background-color: #e6f2f8;
    border-left: 3px solid #0073aa;
}

.lesson-number {
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background-color: #0073aa;
    color: white;
    border-radius: 50%;
    margin-right: 10px;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.lesson-link {
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lesson-link:hover {
    color: #0073aa;
}

/* Header della lezione */
.lesson-header {
    margin-bottom: 2rem;
}

.lesson-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #333;
}

.lesson-meta {
    display: flex;
    align-items: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.lesson-duration {
    display: flex;
    align-items: center;
}

.lesson-duration .dashicons {
    margin-right: 5px;
}

/* Video della lezione */
.lesson-video {
    margin-bottom: 2rem;
}

/* Contenitore video universale */
.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Rapporto 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    background-color: #000; /* Sfondo nero per i video */
}

.video-container iframe,
.video-container object,
.video-container embed,
.video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
}

/* Per compatibilità con la classe esistente */
.video-responsive {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Rapporto 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    background-color: #000; /* Sfondo nero per i video */
}

.video-responsive iframe,
.video-responsive object,
.video-responsive embed,
.video-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
}

/* Supporto specifico per Bunny CDN */
/* 1. Per iframe diretti di Bunny */
iframe[src*="iframe.mediadelivery.net"] {
    border: none !important;
}

/* 2. Per il codice di incorporamento completo di Bunny */
div[style*="position:relative"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 20px !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

div[style*="position:relative"] iframe {
    border: none !important;
}

/* 3. Assicurati che il div contenitore di Bunny sia a larghezza piena */
.lesson-video > div[style*="position:relative"] {
    width: 100% !important;
}

/* 4. Supporto per il player di Bunny */
.bunny-player,
[data-bunny-src],
.bunny-video-player-container,
.bunny-video-player {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    border: none !important;
}

/* Contenuto della lezione */
.lesson-description {
    margin-bottom: 2rem;
    line-height: 1.6;
    color: #333;
}

.lesson-description h2,
.lesson-description h3,
.lesson-description h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.lesson-description p {
    margin-bottom: 1rem;
}

.lesson-description ul,
.lesson-description ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.lesson-description img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1rem 0;
}

.lesson-description code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: monospace;
}

.lesson-description pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

/* Allegati della lezione */
.lesson-attachments {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #0073aa;
}

.lesson-attachments h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: #333;
}

.attachment-link {
    display: flex;
    align-items: center;
    color: #0073aa;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.attachment-link:hover {
    background-color: #e9ecef;
}

.attachment-link .dashicons {
    margin-right: 10px;
    color: #0073aa;
}

/* Navigazione tra le lezioni */
.lesson-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.nav-previous,
.nav-next {
    max-width: 48%;
}

.prev-lesson,
.next-lesson {
    display: block;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    color: #333;
    transition: all 0.2s;
}

.prev-lesson:hover,
.next-lesson:hover {
    background-color: #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-subtitle {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.3rem;
}

.nav-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.nav-previous .prev-lesson {
    padding-left: 2rem;
    position: relative;
}

.nav-next .next-lesson {
    padding-right: 2rem;
    position: relative;
    text-align: right;
}

.nav-previous .prev-lesson:before {
    content: "←";
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
}

.nav-next .next-lesson:after {
    content: "→";
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
}

/* Supporto specifico per il codice di incorporamento di Bunny */
/* Questo gestisce il caso in cui inserisci il codice completo di Bunny */
.lesson-video > div[style*="position:relative;padding-top:56.25%"] {
    width: 100% !important;
    margin-bottom: 20px !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

/* Stili per messaggi di errore video */
.video-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
    border: 1px solid #fca5a5;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.video-error p {
    margin: 0 0 15px 0;
    color: #991b1b;
    font-weight: 500;
}

.video-error p:last-child {
    margin-bottom: 0;
}

.video-fallback-link {
    display: inline-flex;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.video-fallback-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    color: white;
    text-decoration: none;
}

/* Miglioramenti per i player video */
.video-container video {
    border-radius: 8px;
    background: #000;
}

/* Supporto per iframe diretti (qualsiasi provider) */
.video-container iframe {
    border-radius: 8px;
}

/* Stili per il completamento delle lezioni */
.lesson-completion {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.completion-status {
    margin-bottom: 1rem;
}

.lesson-completion-status {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #6c757d;
}

.lesson-completion-status.completed {
    color: #28a745;
}

.lesson-completion-status i {
    margin-right: 0.5rem;
    font-size: 1.2em;
}

.mark-complete-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.mark-complete-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 186, 0.3);
}

.mark-complete-btn.completed {
    background: #28a745;
    border: 2px solid #28a745;
}

.mark-complete-btn.completed:hover {
    background: #218838;
    border-color: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.mark-complete-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.mark-complete-btn i {
    margin-right: 0.5rem;
}

.completion-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-weight: 600;
    text-align: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.completion-success {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    font-weight: 600;
}

/* Stili per la sezione lezioni del corso */
.course-lessons-section {
    margin: 3rem 0;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.course-lessons-section h2 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
    font-size: 1.8rem;
}

/* Barra di progresso */
.course-progress-container {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.progress-label {
    font-weight: 600;
    color: #495057;
}

.progress-percentage {
    font-size: 1.2rem;
    font-weight: 700;
    color: #007cba;
}

.course-progress-bar {
    width: 100%;
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #007cba, #005a87);
    transition: width 0.3s ease;
}

.progress-stats {
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
}

/* Lista delle lezioni */
.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lesson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.lesson-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.lesson-item.completed {
    background: #f8fff9;
    border-color: #28a745;
}

.lesson-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.lesson-number {
    width: 40px;
    height: 40px;
    background: #007cba;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 1rem;
    flex-shrink: 0;
}

.lesson-item.completed .lesson-number {
    background: #28a745;
}

.lesson-details {
    flex: 1;
}

.lesson-title {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
}

.lesson-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
}

.lesson-title a:hover {
    color: #007cba;
}

.lesson-duration {
    display: flex;
    align-items: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.lesson-duration i {
    margin-right: 0.25rem;
}

.lesson-status {
    flex-shrink: 0;
}

.lesson-completed {
    display: flex;
    align-items: center;
    color: #28a745;
    font-weight: 600;
    font-size: 0.9rem;
}

.lesson-completed i {
    margin-right: 0.25rem;
}

.lesson-pending {
    display: flex;
    align-items: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.lesson-pending i {
    margin-right: 0.25rem;
}

.no-lessons-message {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

.super-corso-completato {
    background: linear-gradient(90deg, #10b981, #06b6d4);
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    padding: 2rem 1rem;
    border-radius: 16px;
    margin: 2rem 0;
    box-shadow: 0 4px 24px rgba(16,185,129,0.15);
    letter-spacing: 1px;
    animation: pop 0.5s;
}
@keyframes pop {
    0% { transform: scale(0.8); opacity: 0; }
    80% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
    .lesson-container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .lesson-sidebar {
        width: 100%;
        order: 2;
    }
    
    .lesson-content {
        width: 100%;
        order: 1;
    }
    
    .lesson-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .lesson-status {
        align-self: flex-end;
    }
    
    .progress-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .course-lessons-section {
        padding: 1rem;
    }
    
    .lesson-title {
        font-size: 1.5rem;
    }
    
    .lesson-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-previous,
    .nav-next {
        max-width: 100%;
    }
    
    .video-container {
        margin-bottom: 15px;
    }
    
    .lesson-completion {
        padding: 1rem;
    }
    
    .mark-complete-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .lesson-container {
        padding: 1rem;
    }
    
    .lesson-title {
        font-size: 1.3rem;
    }
    
    .lesson-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .course-info {
        text-align: center;
    }
    
    .course-title {
        font-size: 1.2rem;
    }
    
    .lessons-list h4 {
        font-size: 1.1rem;
    }
    
    .lesson-menu li {
        padding: 0.5rem;
    }
    
    .lesson-number {
        font-size: 0.8rem;
        padding: 2px 6px;
    }
    
    .lesson-link {
        font-size: 0.9rem;
    }
    
    .video-error {
        padding: 15px;
    }
    
    .video-fallback-link {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .lesson-attachments {
        padding: 1rem;
    }
    
    .attachment-link {
        padding: 0.3rem;
        font-size: 0.9rem;
    }
}
