/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #fdab13;
    --secondary-color: #b1aa45;
    --accent-color: #f5740b;
    --text-color: #ffffff;
    --bg-color: #000000;
    --card-bg: #111111;
    --border-color: #444444;
    --success-color: #10b981;
    --error-color: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.7);
    --border-radius: 12px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* HEADER CON IMAGEN DE TÍTULO - Totalmente Responsivo */
.header {
    width: 100%;
    background-color: #000;
    overflow: hidden;
    padding: 1rem 0;
}

.header-image {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 1rem;
}

.title-image {
    width: 100%;
    max-width: clamp(300px, 60vw, 600px);
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.title-image:hover {
    transform: scale(1.02);
}

/* TÍTULOS Responsivos */
section h2 {
    text-align: center;
    color: var(--text-color);
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 2rem;
    padding: 0 1rem;
}

/* ========== SECCIÓN DE VIDEO PRESENTACIÓN - CORREGIDA ========== */
.presentation-section {
    padding: 2rem 0;
}

.video-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: #000;
}

.video-container::before {
    content: '';
    display: block;
    padding-bottom: 56.25%; /* Aspect ratio 16:9 */
}

#presentationVideo {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain; /* Cambié de 'cover' a 'contain' para ver el video completo */
background-color: #000;
border-radius: var(--border-radius);
}

/* SELECTOR DE TIPO DE VIDEO CON IMÁGENES - Completamente Adaptativo */
.video-type-selector {
    display: flex;
    justify-content: center;
    gap: clamp(1rem, 4vw, 3rem);
    margin-bottom: 3rem;
    flex-wrap: wrap;
    padding: 0 1rem;
}

.video-option {
    cursor: pointer;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    padding: 1rem;
    border-radius: var(--border-radius);
    background: var(--card-bg);
    border: 2px solid transparent;
    max-width: 200px;
}

.video-option:hover {
    background: rgba(253, 171, 19, 0.1);
    transform: translateY(-5px);
}

.video-option input {
    display: none;
}

.option-image {
    width: clamp(100px, 25vw, 150px);
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: var(--border-radius);
    border: 3px solid var(--border-color);
    transition: all 0.3s ease;
    object-fit: cover;
    box-shadow: var(--shadow);
}

.option-label {
    color: var(--text-color);
    font-weight: 600;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    text-align: center;
    transition: color 0.3s ease;
}

/* Estado seleccionado */
.video-option input:checked + .option-image {
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(253, 171, 19, 0.5);
}

.video-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(253, 171, 19, 0.15);
}

.video-option:has(input:checked) .option-label {
    color: var(--primary-color);
}

/* FORMULARIO Responsivo */
section {
    padding: 2rem 0;
}

.video-form {
    max-width: 700px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: clamp(1rem, 4vw, 2rem);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    width: 100%;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    color: var(--text-color);
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: #222;
    color: white;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ========== CÁMARA SECCIÓN - COMPLETAMENTE CORREGIDA ========== */
.camera-section {
    margin-top: 2rem;
}

.camera-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.camera-selector label {
    color: var(--text-color);
    font-weight: 500;
}

.camera-selector select,
.camera-selector button {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: #222;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.camera-selector button:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.camera-info {
    background: var(--card-bg);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--primary-color);
    font-weight: 500;
}

/* ========== CONTENEDOR DE VIDEOS DE CÁMARA - NUEVO ========== */
.video-preview-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1rem;
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow);
}

.video-preview-container::before {
    content: '';
    display: block;
    padding-bottom: 56.25%; /* Aspect ratio 16:9 */
}

/* VIDEOS DE CÁMARA - TOTALMENTE RESPONSIVOS Y CORREGIDOS */
#cameraPreview,
#recordedVideo {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain; /* Mantiene la proporción sin recortar */
background: #000;
border: 2px solid var(--border-color);
border-radius: var(--border-radius);
display: block;
}

#recordedVideo {
z-index: 2; /* Para que aparezca encima del preview cuando esté visible */
}

/* CONTROLES DE CÁMARA - Flexibles */
.camera-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.camera-controls button {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: clamp(0.8rem, 2vw, 1rem);
    flex: 1 1 auto;
    min-width: 120px;
    max-width: 200px;
}

.camera-controls button:hover:not(:disabled) {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.camera-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* TIMER */
.recording-timer {
    text-align: center;
    margin-top: 1rem;
    color: var(--error-color);
    font-weight: bold;
    font-size: 1.2rem;
}

/* VIDEOS GRID - Responsivo */
.videos-section {
    padding: 3rem 0;
}

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

/* Estilos para videos en la grid */
.videos-grid video {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #000;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
}

/* LOADING OVERLAY */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ========== MEDIA QUERIES MEJORADAS ========== */

/* Tablets y pantallas medianas */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .video-form {
        margin: 0 15px;
        padding: 1.5rem;
    }

    .camera-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .camera-controls button {
        max-width: none;
        min-width: auto;
    }

    .camera-selector {
        flex-direction: column;
    }

    .camera-selector select,
    .camera-selector button {
        width: 100%;
    }

    .video-type-selector {
        gap: 1.5rem;
    }

    .video-option {
        min-width: 160px;
    }

    /* Videos en tablets */
    .video-preview-container {
        max-width: 500px;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .title-image {
        max-width: 90vw;
    }

    section h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .video-type-selector {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .video-option {
        width: 100%;
        max-width: 180px;
        padding: 1.5rem 1rem;
    }

    .option-image {
        width: 120px;
    }

    .video-form {
        margin: 0 10px;
        padding: 1rem;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 0.6rem;
        font-size: 16px; /* Evita zoom en iOS */
    }

    .videos-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Videos en móviles - Ajuste especial */
    .video-preview-container::before {
        padding-bottom: 75%; /* Aspect ratio 4:3 para móviles */
    }

    .video-container::before {
        padding-bottom: 60%; /* Más compacto para el video de presentación */
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 320px) {
    .container {
        padding: 0 10px;
    }

    .video-form {
        padding: 0.75rem;
    }

    .camera-controls button {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    .video-option {
        max-width: 150px;
        padding: 1rem 0.5rem;
    }

    .option-image {
        width: 100px;
    }

    .video-preview-container {
        max-width: 280px;
    }
}

/* Pantallas grandes */
@media (min-width: 1200px) {
    .video-container {
        max-width: 1000px;
    }

    .video-preview-container {
        max-width: 650px;
    }

    .video-type-selector {
        gap: 4rem;
    }

    .video-option {
        max-width: 220px;
    }
}

/* Orientación landscape en móviles */
@media (max-width: 768px) and (orientation: landscape) {
    .video-type-selector {
        flex-direction: row;
        justify-content: center;
    }

    .video-option {
        max-width: 160px;
    }

    .option-image {
        width: 100px;
    }

    .video-preview-container::before {
        padding-bottom: 56.25%; /* Mantener 16:9 en landscape */
    }

    .title-image {
        max-height: 120px;
    }
}

/* Mejoras para accesibilidad */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666666;
        --card-bg: #1a1a1a;
    }
}

/* Mejora para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .video-option:hover {
        transform: none;
        background: var(--card-bg);
    }

    .video-option:active {
        transform: scale(0.98);
        background: rgba(253, 171, 19, 0.1);
    }
}
