/* ==============================
   RESET Y CONFIGURACIÓN GLOBAL
   ============================== */

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

body {
    font-family: 'Open Sans', sans-serif;
    line-height: 1.6;
    color: #333;
    min-height: 100vh;
    background: transparent; /* El fondo animado está en el HTML */
    overflow-x: hidden;
}

/* Evitar que el fondo se repita o se desplace */
body::before, body::after {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

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

/* ==============================
   HEADER
   ============================== */

header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    padding: 2.5rem 0;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    border-radius: 20px;
    margin-top: 1.5rem;
    border: 1px solid rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(108,92,231,0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
    z-index: 0;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

header h1 {
    font-family: 'Roboto', sans-serif;
    font-size: 2.2rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header p {
    font-size: 1.2rem;
    color: #555;
    position: relative;
    z-index: 2;
    font-weight: 500;
}

/* ==============================
   NAV - ASIGNATURAS
   ============================== */

.asignaturas-nav {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    padding: 1.5rem 0;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    margin-bottom: 2.5rem;
    border: 1px solid rgba(255,255,255,0.3);
}

.asignatura-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 0 10px;
}

.tab-btn, .global-exam {
    padding: 14px 24px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    min-width: 180px;
    text-align: center;
}

.tab-btn:hover, .global-exam:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 30px rgba(108, 92, 231, 0.6);
    background: linear-gradient(135deg, #560bad, #8e7cff);
}

.tab-btn:active, .global-exam:active {
    transform: translateY(2px);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.tab-btn.active {
    background: linear-gradient(135deg, #00b894, #55efc4);
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
}

.tab-btn.active:hover {
    background: linear-gradient(135deg, #00a085, #4cd1ae);
    box-shadow: 0 12px 30px rgba(0, 184, 148, 0.6);
}

.global-exam {
    background: linear-gradient(135deg, #00cec9, #81ecec) !important;
}

.global-exam:hover {
    background: linear-gradient(135deg, #00b2b2, #63d6d6) !important;
    box-shadow: 0 12px 30px rgba(0, 206, 201, 0.6) !important;
}

/* ==============================
   SECCIONES PRINCIPALES
   ============================== */

section {
    display: none;
    animation: fadeIn 0.6s ease-out;
    opacity: 0;
}

section.active-section {
    display: block;
    opacity: 1;
}

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

/* ==============================
   CARD DE BIENVENIDA
   ============================== */

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
    text-align: center;
    margin-bottom: 3rem;
    border: 1px solid rgba(255,255,255,0.5);
    transition: all 0.4s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.card h2 {
    color: #2d3436;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    font-family: 'Roboto', sans-serif;
}

.card p {
    margin-bottom: 1.5rem;
    font-size: 1.15rem;
    color: #636e72;
    line-height: 1.7;
}

.placeholder-img {
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    margin-top: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.placeholder-img:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

/* ==============================
   TOOLBAR Y ACCIONES
   ============================== */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.5);
}

.toolbar h2 {
    color: #2c3e50;
    font-size: 1.9rem;
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ==============================
   BOTONES 3D — ¡ESTRELLA DEL SHOW!
   ============================== */

.btn-primary, .btn-secondary {
    padding: 14px 28px;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

/* Botón Primario (Verde/Azul) */
.btn-primary {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
}

.btn-primary:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 184, 148, 0.6);
    background: linear-gradient(135deg, #00a085, #008a73);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

/* Botón Secundario (Amarillo/Naranja) */
.btn-secondary {
    background: linear-gradient(135deg, #fdcb6e, #fab149);
    color: #2d3436;
    box-shadow: 0 6px 20px rgba(253, 203, 110, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 35px rgba(253, 203, 110, 0.6);
    background: linear-gradient(135deg, #fab149, #f89b29);
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 4px 15px rgba(253, 203, 110, 0.4);
}

/* ==============================
   EJERCICIOS
   ============================== */

.contenedor-ejercicios {
    display: grid;
    gap: 2rem;
    margin-top: 1rem;
}

.ejercicio-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border-left: 6px solid #6c5ce7;
    border: 1px solid rgba(255,255,255,0.5);
    transition: all 0.3s ease;
}

.ejercicio-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.12);
}

.ejercicio-card h3 {
    margin-bottom: 1.5rem;
    color: #2d3436;
    line-height: 1.5;
    font-weight: 600;
    font-size: 1.2rem;
}

.opciones {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 2rem;
}

.opciones label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: rgba(249, 249, 255, 0.7);
    border: 2px solid #e0e0ff;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.opciones label:hover {
    background: rgba(240, 240, 255, 0.9);
    border-color: #c5c5ff;
    transform: translateX(5px);
}

.opciones input[type="radio"] {
    margin-top: 4px;
    transform: scale(1.3);
    cursor: pointer;
}

.feedback {
    margin-top: 16px;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    display: none;
    font-size: 1.05rem;
    text-align: center;
    border: 2px solid transparent;
}

.feedback.correcta {
    background: rgba(212, 237, 218, 0.9);
    color: #1e5d29;
    border-color: #c3e6cb;
    display: block;
    animation: bounceIn 0.5s ease;
}

.feedback.incorrecta {
    background: rgba(248, 215, 218, 0.9);
    color: #842029;
    border-color: #f5c6cb;
    display: block;
    animation: shake 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==============================
   MODAL DE RESULTADOS
   ============================== */

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    overflow: auto;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, #ffffff, #f6f9ff);
    margin: 8% auto;
    padding: 40px;
    border-radius: 28px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 25px 80px rgba(0,0,0,0.4);
    position: relative;
    border: 1px solid rgba(255,255,255,0.7);
    animation: modalEntrance 0.6s ease-out;
}

@keyframes modalEntrance {
    0% { opacity: 0; transform: scale(0.8) translateY(-50px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.close {
    position: absolute;
    right: 30px;
    top: 30px;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: all 0.3s ease;
    padding: 5px 12px;
    border-radius: 50%;
}

.close:hover {
    color: #333;
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

#texto-resultados h2 {
    color: #2c3e50;
    margin-bottom: 2rem;
    font-size: 2rem;
    text-align: center;
}

#texto-resultados p {
    font-size: 1.3rem;
    margin: 15px 0;
    padding: 15px;
    background: rgba(108,92,231,0.05);
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
}

#detalles-errores {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255,245,245,0.7);
    border-radius: 16px;
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #ffe0e0;
}

#detalles-errores h4 {
    margin-bottom: 15px;
    color: #e74c3c;
    text-align: center;
    font-size: 1.3rem;
}

.error-item {
    margin-bottom: 15px;
    padding: 15px;
    background: white;
    border-left: 4px solid #e74c3c;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}

.error-item strong {
    color: #c0392b;
}

/* ==============================
   FOOTER — ¡CRÉDITOS A WEBTICOCR Y LUIS MANUEL COREA!
   ============================== */

footer {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(10px);
    padding: 3rem 0 2rem;
    text-align: center;
    margin-top: 4rem;
    border-radius: 20px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.5);
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #6c5ce7, #00b894, #fdcb6e, #00cec9);
    animation: gradientMove 3s linear infinite;
}

@keyframes gradientMove {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

footer p {
    margin: 10px 0;
    color: #2c3e50;
    line-height: 1.6;
}

footer a {
    color: #6c5ce7;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
    position: relative;
}

footer a:hover {
    color: #560bad;
    text-decoration: underline;
    transform: scale(1.05);
}

/* ==============================
   RESPONSIVE DESIGN
   ============================== */

@media (max-width: 768px) {
    header {
        padding: 1.5rem 0;
        margin-top: 1rem;
        border-radius: 16px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header p {
        font-size: 1rem;
    }

    .asignatura-tabs {
        flex-direction: column;
        align-items: stretch;
        padding: 0 15px;
    }

    .tab-btn, .global-exam {
        width: 100%;
        max-width: none;
        margin-bottom: 8px;
        min-width: auto;
        font-size: 1rem;
        padding: 16px 20px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 1.2rem;
    }

    .toolbar h2 {
        font-size: 1.5rem;
        justify-content: center;
        text-align: center;
    }

    .actions {
        width: 100%;
        justify-content: center;
    }

    .card {
        padding: 2rem 1.5rem;
    }

    .card h2 {
        font-size: 1.6rem;
    }

    .modal-content {
        padding: 30px 20px;
        margin: 15% auto;
    }

    .close {
        right: 15px;
        top: 15px;
        font-size: 28px;
    }

    .ejercicio-card {
        padding: 1.5rem;
    }

    .feedback {
        font-size: 1rem;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 10px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .tab-btn, .global-exam {
        padding: 14px 16px;
        font-size: 0.95rem;
    }

    .btn-primary, .btn-secondary {
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .modal-content {
        margin: 20% auto;
        padding: 25px 15px;
    }
}

/* ==============================
   ANIMACIONES ADICIONALES
   ============================== */

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.card {
    animation: float 6s ease-in-out infinite;
    animation-delay: 0.5s;
}

.card:nth-child(2) { animation-delay: 1s; }
.card:nth-child(3) { animation-delay: 1.5s; }

/* Efecto sutil al cargar */
body {
    opacity: 0;
    animation: fadeInBody 1s ease forwards;
}

@keyframes fadeInBody {
    to { opacity: 1; }
}

/*LOGIN GOOGLE***********************/

/* ==============================
   MODAL DE LOGIN CON GOOGLE
   ============================== */

.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

#login-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 3rem;
    border-radius: 28px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
    text-align: center;
    position: relative;
    z-index: 2;
    max-width: 90%;
    width: 450px;
    animation: modalEntrance 0.6s ease-out;
}

@keyframes modalEntrance {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.logo-preview h1 {
    font-family: 'Roboto', sans-serif;
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #6c5ce7, #00b894);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-preview p {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.auth-message {
    margin: 1.5rem 0;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    display: none;
}

.auth-message.success {
    background: rgba(212, 237, 218, 0.9);
    color: #1e5d29;
    display: block;
}

.auth-message.error {
    background: rgba(248, 215, 218, 0.9);
    color: #842029;
    display: block;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: white;
    color: #444;
    border: 2px solid #ddd;
    padding: 14px 28px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-google:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    background: #fafafa;
}

.btn-google svg {
    width: 24px;
    height: 24px;
}

.btn-google span {
    font-weight: 600;
}

.login-footer {
    margin-top: 2rem;
    font-size: 0.9rem;
    color: #666;
}

.login-footer p {
    margin: 5px 0;
}

/* Estilo para el avatar y nombre (en header) */
.user-info {
    display: none;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-left: auto;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #6c5ce7;
}

#user-name {
    font-weight: 600;
    color: #2c3e50;
}

#logout-btn {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 10px;
    padding: 5px 10px;
    border-radius: 12px;
    transition: all 0.2s;
}

#logout-btn:hover {
    background: rgba(231, 76, 60, 0.1);
}