*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: 'Nunito', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

@media (pointer: coarse) {
  * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ── BACKGROUND IMAGES ── */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -3;
    background-image: url('src/fondo-claves-movil.png');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    pointer-events: none;
}

@media (min-width: 768px) {
    .background-container {
        background-image: url('src/fondo-claves-web.png');
    }
}

/* ── CAPA DE NUBES (z-index bajo, detrás del logo) ── */
.clouds-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.cloud {
    position: absolute;
    left: -300px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes drift {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc(100vw + 400px));
    }
}

.c1 {
    top: 5%;
    animation: drift 35s linear infinite;
}

.c2 {
    top: 15%;
    animation: drift 45s linear infinite -15s;
    opacity: 0.9;
}

.c3 {
    top: 3%;
    animation: drift 40s linear infinite -28s;
    opacity: 0.8;
}

.c4 {
    top: 22%;
    animation: drift 52s linear infinite -38s;
    opacity: 0.85;
}

/* ── WRAPPER PRINCIPAL ── */
.page {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 440px;
    padding: 32px 20px 110px;
    min-height: 100vh;
    justify-content: center;
}

/* Variante ancha para páginas con tablas/listados */
.page.page-wide {
    max-width: 960px;
    justify-content: flex-start;
}

.page.page-wide .card {
    padding: 28px 26px;
}

@media (max-width: 600px) {
    .page.page-wide {
        padding: 20px 14px 100px;
    }

    .page.page-wide .card {
        padding: 22px 16px;
        border-radius: 18px;
    }
}

/* ── LOGO (z-index: 20, SIEMPRE por delante de las nubes) ── */
.logo-wrap {
    position: relative;
    z-index: 20;
    text-align: center;
    margin-bottom: 28px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
    animation: logoEntrance 0.7s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes logoEntrance {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.logo-claves {
    position: relative;
    display: inline-block;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── CARD ── */
.card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 28px;
    padding: 36px 32px;
    width: 100%;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.13);
    position: relative;
    z-index: 20;
    animation: cardEntrance 0.6s ease 0.2s both;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card h2 {
    font-size: 22px;
    font-weight: 800;
    color: #1a1a2e;
    text-align: center;
    margin-bottom: 6px;
}

.card p.subtitle {
    font-size: 15px;
    color: #999;
    text-align: center;
    margin-bottom: 28px;
}

/* ── INPUTS ── */
.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #4A90D9;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    border: 1.8px solid #E8ECF0;
    border-radius: 14px;
    padding: 15px 48px 15px 46px;
    font-size: 15px;
    font-family: 'Nunito', sans-serif;
    color: #333;
    background: #FAFAFA;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.input-group input:focus {
    border-color: #4A90D9;
    box-shadow: 0 0 0 4px rgba(74, 144, 217, 0.14);
    background: #fff;
}

.input-group input::placeholder {
    color: #c0c0c0;
}

.btn-eye {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #bbb;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.btn-eye:hover {
    color: #666;
}

/* ── FORGOT ── */
.forgot {
    display: block;
    text-align: center;
    color: #4A90D9;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    margin: 6px 0 24px;
    transition: opacity 0.2s;
}

.forgot:hover {
    opacity: 0.75;
    text-decoration: underline;
}

/* ── BOTÓN ── */
.btn-login {
    width: 100%;
    background: linear-gradient(135deg, #2979FF 0%, #1565C0 100%);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 17px;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(41, 121, 255, 0.45);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    letter-spacing: 0.3px;
}

.btn-login:hover {
    filter: brightness(1.1);
    box-shadow: 0 8px 24px rgba(41, 121, 255, 0.55);
}

.btn-login:active {
    transform: scale(0.97);
    box-shadow: 0 3px 10px rgba(41, 121, 255, 0.35);
}

/* ── MENSAJE DE ERROR ── */
.error-msg {
    display: none;
    background: #FFF3F3;
    border: 1.5px solid #FFCDD2;
    color: #C62828;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
    text-align: center;
}

.error-msg.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-6px);
    }

    75% {
        transform: translateX(6px);
    }
}

/* ── DINOSAURIO / MASCOTA ── */
.dino-container {
    position: fixed;
    bottom: -5px;
    left: 70px !important;
    z-index: 30;
    width: 110px;
    animation: dinoEntrance 0.8s cubic-bezier(.34, 1.56, .64, 1) 0.4s both;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.dino-container img {
    animation: dinoJump 3s ease-in-out 1.2s infinite;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.45));
}

@keyframes dinoEntrance {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.6);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes dinoJump {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-12px) scale(1.02);
    }
}

.dino-container.jump-active img {
    animation: dinoActiveJump 0.45s cubic-bezier(.34, 1.56, .64, 1) 4 !important;
}

@keyframes dinoActiveJump {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-35px) scale(1.05);
    }
}

@media (min-width: 768px) {
    .dino-container {
        width: 170px;
        bottom: -15px;
        left: 375px !important;
    }
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
    .page {
        padding: 20px 16px 90px;
        /* Reducimos padding para dar más espacio vertical */
    }

    .logo-claves {
        max-width: 230px !important;
        /* Hacemos el logo más pequeño */
    }

    .logo-wrap {
        margin-bottom: 16px;
    }

    .card {
        padding: 24px 18px;
        border-radius: 20px;
        /* Bordes menos pronunciados en móvil */
    }

    .card h2 {
        font-size: 18px;
        margin-bottom: 4px;
    }

    .card p.subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .input-group {
        margin-bottom: 12px;
    }

    .input-group input {
        padding: 12px 40px 12px 42px;
        font-size: 14px;
    }

    .input-icon,
    .btn-eye {
        transform: translateY(-50%) scale(0.9);
    }

    .btn-login {
        padding: 12px;
        font-size: 15px;
    }

    .forgot {
        font-size: 13px;
        margin: 4px 0 16px;
    }

    .dino-container {
        width: 90px;
        left: 40px !important;
        bottom: -5px;
    }
}

/* ── MODO PROFESOR (paleta verde) ── */
body.teacher-theme .btn-volver,
body.teacher-theme .btn-panel,
body.teacher-theme .btn-back {
    color: #16a34a;
}

body.teacher-theme .btn-volver:hover,
body.teacher-theme .btn-panel:hover {
    background: #d1fae5;
}

body.teacher-theme .btn-detalle,
body.teacher-theme .btn-action.blue,
body.teacher-theme .btn-add {
    background: #16a34a !important;
}

body.teacher-theme .btn-detalle:hover,
body.teacher-theme .btn-add:hover {
    background: #15803d !important;
}

body.teacher-theme .form-box {
    border-color: #16a34a !important;
    background: #f0fdf4 !important;
}

body.teacher-theme .form-box label,
body.teacher-theme .sesion-fecha {
    color: #166534 !important;
}

body.teacher-theme .form-box textarea:focus,
body.teacher-theme .form-box input:focus {
    border-color: #16a34a !important;
}

body.teacher-theme .alumno-avatar {
    background: #dcfce7 !important;
    border-color: #86efac !important;
}

body.teacher-theme .alumno-avatar .ini {
    color: #166534 !important;
}

body.teacher-theme .fecha-fija {
    color: #166534 !important;
    background: #d1fae5 !important;
}

body.teacher-theme .grupos-table th,
body.teacher-theme .alumnos-table th,
body.teacher-theme .sesiones-list .sesion-fecha {
    color: #166534;
}

body.teacher-theme .grupos-table tr:hover,
body.teacher-theme .alumnos-table tr:hover {
    background: #f0fdf4;
}

/* Badge "Modo profesor" en la cabecera */
body.teacher-theme .card h2::after {
    content: " · Profesor";
    color: #16a34a;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 6px;
    padding: 3px 8px;
    background: #dcfce7;
    border-radius: 999px;
}
