* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --bg-dark: #1e293b;
    --bg-light: #f8fafc;
    --sidebar-bg: #0f172a;
    --text-dark: #1e293b;
    --text-light: #f8fafc;
    --border-color: #e2e8f0;
    --hover-color: #334155;
    --success-color: #10b981;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: #5a67d8;
    min-height: 100vh;
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Overlay para sidebar en móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.container {
    display: flex;
    max-width: 1920px;
    margin: 0 auto;
    min-height: 100vh;
    background: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* SIDEBAR */
.sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    color: var(--text-light);
    overflow-y: auto;
    transition: transform 0.3s ease;
    position: relative;
    border-right: 3px solid var(--primary-color);
    z-index: 10;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    background: var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header i {
    margin-right: 0.5rem;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.toggle-btn i {
    margin: 0;
}

.video-list {
    padding: 1rem 0;
    position: relative;
    z-index: 5;
}

.category-section {
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.category-title {
    padding: 1rem 1.5rem;
    background: rgba(59, 130, 246, 0.2);
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 4px solid var(--accent-color);
    margin-bottom: 0.5rem;
}

.video-item {
    padding: 1rem 1.5rem;
    cursor: pointer !important;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    user-select: none;
    position: relative;
    z-index: 1;
}

.video-item:hover {
    background: var(--hover-color);
    border-left-color: var(--accent-color);
    transform: translateX(5px);
}

.video-item.active {
    background: var(--primary-color);
    border-left-color: var(--success-color);
    font-weight: 600;
}


.video-item-number {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 30px;
    pointer-events: none;
}

.video-item-title {
    font-size: 0.9rem;
    line-height: 1.4;
    pointer-events: none;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    padding: 2rem;
    background: var(--bg-light);
    overflow-y: auto;
}

.video-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.video-header {
    margin-bottom: 1.5rem;
}

.video-header h2 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.video-info {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
}

.video-number {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.video-category {
    background: var(--bg-light);
    color: var(--text-dark);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.video-player-wrapper {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

#videoPlayer {
    width: 100%;
    height: auto;
    max-height: 70vh;
    display: block;
    background: #000;
}

/* Estilos específicos para iOS y móviles */
#videoPlayer::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

#videoPlayer::-webkit-media-controls-play-button {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
}

.no-video-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f1f5f9;
}

.welcome-message i {
    margin-right: 0.5rem;
}

.no-video-message.hidden {
    display: none;
}

.welcome-message {
    text-align: center;
    padding: 2rem;
}

.welcome-message h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.welcome-message p {
    font-size: 1.2rem;
    color: #64748b;
    margin-bottom: 2rem;
}

.start-btn {
    padding: 1.2rem 3rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.start-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

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

.video-controls {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.nav-btn {
    flex: 1;
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn i {
    margin: 0 0.3rem;
}

.nav-btn:hover:not(:disabled) {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.nav-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.5;
}

.video-description {
    padding: 1.5rem;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    color: var(--text-dark);
    line-height: 1.6;
}

/* PROGRESS BAR */
.progress-bar {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.progress-fill {
    height: 30px;
    background: var(--primary-color);
    border-radius: 15px;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.95rem;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .toggle-btn {
        display: block;
    }

    .main-content {
        width: 100%;
    }

    .container {
        flex-direction: column;
    }

    /* Overlay/Backdrop cuando el sidebar está abierto */
    .sidebar.active::after {
        content: '';
        position: fixed;
        top: 0;
        left: 350px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 16px; /* Previene zoom en iOS */
    }

    .sidebar {
        width: 85vw;
        max-width: 320px;
    }

    .sidebar.active::after {
        left: 85vw;
    }

    .main-content {
        padding: 1rem;
    }

    .video-container {
        padding: 1rem;
    }

    .video-header h2 {
        font-size: 1.3rem;
        line-height: 1.4;
    }

    .video-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .video-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .nav-btn {
        width: 100%;
        padding: 1.2rem 2rem; /* Touch target mínimo 44px */
        font-size: 1.1rem;
    }

    .start-btn {
        width: 100%;
        padding: 1.2rem 2rem;
    }

    .video-item {
        padding: 1.2rem 1.5rem; /* Touch target más grande */
        font-size: 1rem;
    }

    .category-title {
        padding: 1.2rem 1.5rem;
        font-size: 0.9rem;
    }

    #videoPlayer {
        max-height: 50vh;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .welcome-message p {
        font-size: 1rem;
    }
}

/* Pantallas muy pequeñas (iPhone SE, etc) */
@media (max-width: 375px) {
    .sidebar {
        width: 90vw;
    }

    .video-header h2 {
        font-size: 1.1rem;
    }

    .nav-btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .video-item {
        padding: 1rem 1rem;
    }
}

/* Optimizaciones para iOS Safari */
@supports (-webkit-touch-callout: none) {
    .video-player-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    .sidebar {
        -webkit-overflow-scrolling: touch;
    }

    input, button, select {
        -webkit-appearance: none;
        border-radius: 0;
    }

    .nav-btn {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
    }

    .video-item {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
    }
}

/* SCROLLBAR */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}
