/* ============================================
   PROTOCOLO DESINCHA 10X - ESTILOS
   ============================================ */

/* VARIABLES - COLORES DESINCHA */
:root {
    --primary-purple: #1a0033;
    --primary-purple-light: #4a2080;
    --accent-green: #00d167;
    --accent-yellow: #ffd700;
    --accent-magenta: #ff00ff;
    --text-dark: #1a1a1a;
    --text-light: #666666;
    --bg-light: #f8f8f8;
    --border-color: #eeeeee;
    --shadow: 0 2px 12px rgba(26, 0, 51, 0.1);
    --shadow-large: 0 4px 20px rgba(26, 0, 51, 0.15);
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-purple-light);
}

/* ============================================
   HEADER STICKY
   ============================================ */
.header-sticky {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
    color: white;
    padding: 16px;
    box-shadow: var(--shadow);
    padding-top: max(16px, env(safe-area-inset-top));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.header-title h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-logout {
    background: rgba(255, 215, 0, 0.2);
    color: white;
    border: 1.5px solid var(--accent-yellow);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-logout:active {
    background: rgba(255, 215, 0, 0.3);
    transform: scale(0.95);
}

/* ============================================
   BARRA DE PROGRESO
   ============================================ */
.progress-bar-container {
    padding: 16px;
    background-color: var(--bg-light);
    border-bottom: 2px solid var(--accent-green);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-percent {
    color: var(--accent-green);
    font-weight: 700;
    font-size: 14px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green) 0%, var(--accent-yellow) 100%);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 4px;
}

/* ============================================
   CONTENEDOR DE MÓDULOS
   ============================================ */
.modules-container {
    padding: 16px;
    max-width: 100%;
    padding-bottom: 32px;
}

.module-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.module-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

.module-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.module-number {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 45px;
    text-align: center;
}

.module-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.module-info h3 {
    font-size: 15px;
    margin-bottom: 4px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--text-dark);
}

.module-duration {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.module-status {
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-pending {
    background: linear-gradient(135deg, var(--accent-yellow), #ffed4e);
    color: var(--primary-purple);
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.badge-completed {
    background: linear-gradient(135deg, var(--accent-green), #00f084);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(0, 209, 103, 0.3);
}

.progress-bar-small {
    width: 100%;
    height: 6px;
    background-color: #ddd;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill-small {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green) 0%, var(--accent-yellow) 100%);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-play {
    display: inline-block;
    width: 100%;
    padding: 12px 16px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(26, 0, 51, 0.2);
}

.btn-play:active {
    transform: scale(0.98);
    box-shadow: 0 2px 6px rgba(26, 0, 51, 0.15);
}

/* ============================================
   HEADER MÓDULO
   ============================================ */
.header-modulo {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    padding-top: max(12px, env(safe-area-inset-top));
}

.btn-back {
    background: rgba(255, 215, 0, 0.2);
    color: white;
    border: 1.5px solid var(--accent-yellow);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-back:active {
    background: rgba(255, 215, 0, 0.3);
    transform: scale(0.95);
}

.header-modulo h1 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

/* ============================================
   VIDEO CONTAINER
   ============================================ */
.video-container {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, rgba(26, 0, 51, 0.05), rgba(0, 209, 103, 0.05));
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-large);
    background: #000;
}

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

/* ============================================
   MÓDULO INFO
   ============================================ */
.modulo-info {
    padding: 20px 16px;
}

.modulo-info h2 {
    font-size: 18px;
    margin-bottom: 8px;
    line-height: 1.3;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modulo-info .duration {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 12px;
    font-weight: 600;
}

.modulo-info .description {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.7;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.action-buttons {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-primary, .btn-secondary {
    padding: 14px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-green) 0%, #00f084 100%);
    color: white;
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

.btn-primary:disabled {
    background: linear-gradient(135deg, #ccc, #ddd);
    cursor: not-allowed;
    color: #666;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 100%);
    color: white;
}

.btn-secondary:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-large);
}

.btn-full {
    width: 100%;
    display: block;
}

/* ============================================
   PROGRESS STATUS
   ============================================ */
.progress-status {
    text-align: center;
    padding: 14px 16px;
    font-size: 12px;
    color: var(--text-light);
    background-color: var(--bg-light);
    margin: 0 16px 16px 16px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-green);
    font-weight: 500;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-light) 50%, var(--accent-magenta) 100%);
    padding: 16px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 32px 16px;
    box-shadow: var(--shadow-large);
    text-align: center;
}

.login-box .logo {
    max-width: 160px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(26, 0, 51, 0.15);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-purple), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
}

.login-box .subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 28px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 4px rgba(26, 0, 51, 0.08);
    background-color: rgba(26, 0, 51, 0.02);
}

.form-group input::placeholder {
    color: #aaa;
}

.error-message {
    color: #ff4757;
    font-size: 12px;
    margin-top: 12px;
    display: none;
    background: rgba(255, 71, 87, 0.08);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #ff4757;
    font-weight: 500;
}

.error-message.show {
    display: block;
}

.demo-credentials {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    background: linear-gradient(135deg, rgba(26, 0, 51, 0.02), rgba(0, 209, 103, 0.02));
    padding: 14px 12px;
    border-radius: 8px;
    border-left: 3px solid var(--accent-green);
}

.demo-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0px;
}

.demo-subtitle {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
}

/* ============================================
   INSTALL PROMPT
   ============================================ */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(26, 0, 51, 0.15);
    z-index: 999;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 2px solid var(--accent-green);
}

.install-prompt p {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.btn-install {
    background: linear-gradient(135deg, var(--accent-green), #00f084);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.btn-install:active {
    transform: scale(0.95);
}

/* ============================================
   CERTIFICATE
   ============================================ */
.certificate-section {
    padding: 16px;
    margin: 0 16px 16px 16px;
}

.certificate-box {
    background: linear-gradient(135deg, rgba(26, 0, 51, 0.05), rgba(0, 209, 103, 0.05));
    border: 2px solid var(--accent-green);
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    animation: slideUp 0.4s ease;
}

.certificate-box h3 {
    font-size: 18px;
    color: var(--accent-green);
    margin-bottom: 8px;
    font-weight: 700;
}

.certificate-box p {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
    font-weight: 500;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (min-width: 768px) {
    .modules-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    
    .action-buttons {
        flex-direction: row;
    }
    
    .action-buttons .btn-primary,
    .action-buttons .btn-secondary {
        flex: 1;
    }
}

/* ============================================
   RESPONSIVE - DESKTOP
   ============================================ */
@media (min-width: 1024px) {
    .modules-container {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .login-container {
        max-width: 450px;
    }
    
    .login-box {
        padding: 40px 32px;
    }
}

/* ============================================
   ESTADO DE SEGURIDAD OFFLINE
   ============================================ */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================
   MODO OSCURO (si el usuario lo prefiere)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --text-dark: #f0f0f0;
        --text-light: #a0a0a0;
        --bg-light: #1a1a1a;
        --border-color: #333333;
    }
    
    html, body {
        background-color: #0a0a0a;
        color: var(--text-dark);
    }
    
    .module-card,
    .login-box {
        background: #1a1a1a;
        border-color: #333333;
    }
    
    .demo-credentials {
        background: linear-gradient(135deg, rgba(26, 0, 51, 0.1), rgba(0, 209, 103, 0.05));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .header-sticky,
    .header-modulo,
    .action-buttons,
    .btn-logout {
        display: none;
    }
    
    .video-container {
        display: none;
    }
}
