/* Estilos para el Modal de Video - Academia RutaConecta */

.video-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.video-modal.active {
    opacity: 1;
    visibility: visible;
}

.video-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.video-modal-content {
    position: relative;
    width: 90%;
    max-width: 1000px;
    max-height: 95vh;
    background: var(--elev);
    border: 1px solid var(--stroke);
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.video-modal.active .video-modal-content {
    transform: scale(1);
}

.video-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--stroke);
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 5%, var(--elev)), var(--elev));
}

.video-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    flex: 1;
    margin-right: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.video-modal-close:hover {
    background: color-mix(in srgb, var(--brand) 15%, transparent);
    color: var(--brand);
}

.video-modal-body {
    padding: 0;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.video-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 60vh;
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}

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

.video-modal-info {
    padding: 1.5rem;
    background: var(--elev);
    overflow-y: auto;
    flex-shrink: 0;
}

.video-modal-info .video-description {
    color: var(--muted);
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.video-modal-info .video-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid var(--stroke);
}

.video-modal-info .video-category {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--brand);
    font-weight: 500;
    font-size: 0.95rem;
}

.video-modal-info .video-category .material-icons {
    font-size: 1.1rem;
}

.video-modal-info .video-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .video-modal {
        align-items: flex-end;
        padding: 0;
    }
    
    .video-modal-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    
    .video-modal.active .video-modal-content {
        transform: translateY(0);
    }
    
    .video-modal-header {
        padding: 1rem;
        border-bottom: 1px solid var(--stroke);
        flex-shrink: 0;
    }
    
    .video-modal-header h3 {
        font-size: 1.1rem;
        margin-right: 0.5rem;
    }
    
    .video-modal-close {
        width: 36px;
        height: 36px;
    }
    
    .video-embed {
        max-height: 50vh;
    }
    
    .video-modal-info {
        padding: 1rem;
    }
    
    .video-modal-info .video-description {
        font-size: 0.95rem;
    }
    
    .video-modal-info .video-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
}

@media (max-width: 480px) {
    .video-modal-content {
        max-height: 85vh;
    }
    
    .video-modal-header {
        padding: 0.8rem;
    }
    
    .video-modal-header h3 {
        font-size: 1rem;
    }
    
    .video-modal-info {
        padding: 0.8rem;
    }
    
    .video-modal-close {
        width: 32px;
        height: 32px;
    }
    
    .video-embed {
        max-height: 45vh;
    }
}

/* Animaciones adicionales */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.video-modal.active .video-modal-backdrop {
    animation: fadeIn 0.3s ease;
}

.video-modal.active .video-modal-content {
    animation: slideInUp 0.3s ease 0.1s both;
}

/* Scrollbar personalizado para el modal */
.video-modal-body::-webkit-scrollbar {
    width: 6px;
}

.video-modal-body::-webkit-scrollbar-track {
    background: var(--elev);
}

.video-modal-body::-webkit-scrollbar-thumb {
    background: var(--stroke);
    border-radius: 3px;
}

.video-modal-body::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--brand) 30%, var(--stroke));
}

/* Estilos para modo oscuro/claro */
@media (prefers-color-scheme: light) {
    .video-modal {
        background: rgba(255, 255, 255, 0.1);
    }
}

@media (prefers-color-scheme: dark) {
    .video-modal {
        background: rgba(0, 0, 0, 0.1);
    }
}

/* Estados de carga */
.video-embed.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--elev);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.video-embed.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--stroke);
    border-top: 4px solid var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Mejoras de accesibilidad */
.video-modal[aria-hidden="true"] {
    pointer-events: none;
}

.video-modal:focus-within .video-modal-close {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.video-modal-close:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Estados hover en desktop */
@media (hover: hover) {
    .video-modal-close:hover .material-icons {
        transform: scale(1.1);
        transition: transform 0.2s ease;
    }
    
    .video-modal-content:hover {
        box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
    }
}