/* ===========================
   COMPOSANTS INTERACTIFS
   Pour enrichir les leçons IBODE
   =========================== */

/* Galerie d'images */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 1rem;
    font-size: 0.9rem;
}

/* Lightbox pour zoom images */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 2rem;
    padding: 1rem;
    cursor: pointer;
    border-radius: 8px;
    user-select: none;
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

/* Viewer 3D */
.viewer-3d {
    width: 100%;
    height: 500px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px;
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.viewer-3d canvas {
    width: 100%;
    height: 100%;
}

.viewer-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 50px;
    display: flex;
    gap: 1rem;
}

.viewer-controls button {
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s, background 0.2s;
}

.viewer-controls button:hover {
    transform: scale(1.1);
    background: var(--primary-color);
    color: white;
}

.viewer-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

/* Schémas 2D annotés */
.diagram-2d {
    position: relative;
    margin: 2rem 0;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.diagram-2d img {
    width: 100%;
    display: block;
}

.diagram-annotation {
    position: absolute;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
}

.diagram-annotation::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
}

.diagram-annotation:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.diagram-annotation.active {
    background: var(--success-color);
}

.annotation-popup {
    position: absolute;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    max-width: 300px;
    z-index: 100;
    display: none;
}

.annotation-popup.active {
    display: block;
}

.annotation-popup h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

.annotation-popup p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Intégration vidéos */
.video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Ratio 16:9 */
    margin: 2rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-playlist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.video-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.video-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary-color);
}

.video-info {
    padding: 1rem;
}

.video-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-dark);
}

.video-info p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-light);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Section de ressources enrichies */
.rich-section {
    background: var(--bg-light);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 8px;
}

.rich-section h3 {
    color: var(--primary-color);
    margin-top: 0;
}

.resource-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.resource-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.3s;
    position: relative;
}

.resource-tab.active {
    color: var(--primary-color);
}

.resource-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.resource-content {
    display: none;
}

.resource-content.active {
    display: block;
}

/* Timeline interactive */
.procedure-timeline {
    position: relative;
    padding-left: 3rem;
    margin: 2rem 0;
}

.timeline-step {
    position: relative;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.timeline-step::before {
    content: '';
    position: absolute;
    left: -3rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--primary-color);
}

.timeline-step::after {
    content: attr(data-step);
    position: absolute;
    left: -4.5rem;
    top: 1.5rem;
    width: 3rem;
    height: 3rem;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.timeline-step h4 {
    margin-top: 0;
    color: var(--primary-color);
}

/* Comparaison avant/après */
.before-after {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 2rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.before-after img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.before-after .after {
    clip-path: inset(0 50% 0 0);
}

.ba-slider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: white;
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.ba-slider::before {
    content: '◄►';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 0.5rem;
    border-radius: 50%;
    font-size: 1rem;
}

/* Notes cliniques */
.clinical-note {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-left: 4px solid #f59e0b;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.clinical-note::before {
    content: '⚠️ Note clinique';
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #92400e;
}

.tip-box {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.tip-box::before {
    content: '💡 Astuce pratique';
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.warning-box {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-left: 4px solid #dc2626;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.warning-box::before {
    content: '🚨 Attention';
    display: block;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #991b1b;
}

/* Responsive */
@media (max-width: 768px) {
    .image-gallery {
        grid-template-columns: 1fr;
    }
    
    .video-playlist {
        grid-template-columns: 1fr;
    }
    
    .viewer-3d {
        height: 300px;
    }
    
    .procedure-timeline {
        padding-left: 2rem;
    }
    
    .timeline-step::after {
        left: -3.5rem;
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.9rem;
    }
}
