:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #60a5fa;
    --primary-rgb: 37, 99, 235;
    --accent: #818cf8;
    
    --bg-dark: #080b14;
    --card-bg: #111729; /* Fixed solid dark background for card to support floating labels masking */
    --card-bg-glass: rgba(17, 23, 41, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.16);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-secondary: #cbd5e1;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --error-border: rgba(239, 68, 68, 0.25);
    --error-text: #fca5a5;

    --transition-premium: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Enforce no-scroll on desktop screens */
@media (min-width: 1025px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
}

/* Page Wrapper for Split View */
.login-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    position: relative;
    z-index: 1;
}

@media (min-width: 1025px) {
    .login-wrapper {
        height: 100vh;
        overflow: hidden;
    }
}

/* Background animated glow mesh (visible behind forms) */
.bg-glow-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.glow-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    animation: floatBlob 20s infinite alternate ease-in-out;
}

.glow-blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.glow-blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
    animation-delay: -5s;
    animation-duration: 25s;
}

.glow-blob-3 {
    top: 30%;
    left: 40%;
    width: 35vw;
    height: 35vw;
    background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
    animation-delay: -10s;
    animation-duration: 18s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(5%, 10%) scale(1.1); }
    100% { transform: translate(-5%, -5%) scale(0.95); }
}

/* Visual Panel (Left Side on Desktop) */
.login-visual-panel {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--glass-border);
    background: #050811;
}

.login-visual-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../img/Fondo.webp') no-repeat center center;
    background-size: cover;
    opacity: 0.55; /* More visible high quality background */
    pointer-events: none;
    transition: transform 10s ease-out;
}

.login-visual-panel:hover::before {
    transform: scale(1.05); /* Soft premium zoom effect on hover */
}

/* Frosted glass overlay on top of background image */
.visual-glass-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(8, 11, 20, 0.75) 0%, rgba(8, 11, 20, 0.45) 100%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1;
}

.visual-header {
    z-index: 2;
}

.visual-header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.visual-header-logo img {
    height: 48px;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.4));
}

.visual-header-logo span {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: white;
}

.visual-content {
    z-index: 2;
    max-width: 600px;
    margin: auto 0;
}

.visual-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(37, 99, 235, 0.2);
    border: 1px solid rgba(37, 99, 235, 0.4);
    color: var(--primary-light);
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15);
}

.visual-badge i {
    font-size: 0.8rem;
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.visual-title {
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 1rem;
    letter-spacing: -1.5px;
    color: white;
}

.visual-title span {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.visual-description {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.75rem;
    opacity: 0.9;
}

/* Feature Mockup Dashboard Row */
.features-grid-custom {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.glass-feature-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.5rem;
    border-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: var(--transition-premium);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glass-feature-card:hover {
    transform: translateY(-6px);
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 15px rgba(37, 99, 235, 0.1);
}

.glass-feature-card-icon {
    width: 44px;
    height: 44px;
    background: rgba(37, 99, 235, 0.15);
    color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-size: 1.25rem;
    border: 1px solid rgba(37, 99, 235, 0.25);
}

.glass-feature-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
}

.glass-feature-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.visual-footer {
    z-index: 2;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Form Panel (Right Side on Desktop, Full Screen on Mobile) */
.login-form-panel {
    flex: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    background-color: transparent;
}

.login-card {
    width: 100%;
    max-width: 450px;
    background: var(--card-bg-glass);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 2.25rem 2rem;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.5);
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 10;
}

/* Header Section */
.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.school-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 0.85rem auto;
    display: block;
    filter: drop-shadow(0 0 15px rgba(37, 99, 235, 0.25));
    animation: float 6s ease-in-out infinite;
}

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

.app-name {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.35rem;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 400;
}

/* Role Selector Tabs */
.role-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    padding: 5px;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--glass-border);
    position: relative;
    gap: 4px;
}

.role-tab {
    flex: 1;
    padding: 10px 14px;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.role-tab i {
    font-size: 0.95rem;
}

.role-tab.active {
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.role-tab:not(.active):hover {
    color: white;
    background: rgba(255, 255, 255, 0.03);
}

/* Floating Helper Message */
.role-helper-text {
    font-size: 0.82rem;
    color: var(--primary-light);
    margin-top: -1rem;
    margin-bottom: 1.25rem;
    padding-left: 0.25rem;
    min-height: 20px;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Form Styles with Floating Labels */
.form-group {
    margin-bottom: 1.25rem;
    position: relative;
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }
.form-group:nth-child(3) { animation-delay: 0.3s; }

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

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-container > i:first-of-type {
    position: absolute;
    left: 1.25rem;
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
    transition: color 0.3s ease;
    z-index: 4;
}

.form-control {
    width: 100%;
    padding: 1.55rem 3rem 0.65rem 3.25rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1.5px solid var(--glass-border);
    border-radius: 16px;
    color: white;
    font-size: 0.95rem;
    font-weight: 400;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide native placeholder to trigger :placeholder-shown */
.form-control::placeholder {
    color: transparent;
}

/* Floating Label Styles */
.input-container label {
    position: absolute;
    left: 3.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 3;
}

/* Shift label upwards on focus or when input is occupied */
.form-control:focus ~ label,
.form-control:not(:placeholder-shown) ~ label {
    top: 13px;
    left: 3.25rem;
    transform: none;
    font-size: 0.72rem;
    color: var(--primary-light);
    font-weight: 600;
    background: transparent;
    z-index: 5;
    padding: 0;
}

.form-control:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.55);
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.form-control:focus ~ i:first-of-type {
    color: var(--primary-light);
}

/* LED validation line */
.validation-line {
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2.5px;
    background: transparent;
    border-radius: 2px;
    transition: all 0.4s ease;
    z-index: 6;
    pointer-events: none;
}

.validation-line.valid {
    background: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
}

.validation-line.invalid {
    background: var(--error);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Password Toggle icon */
.btn-toggle-password {
    position: absolute;
    right: 1.1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    font-size: 1rem;
    transition: color 0.3s ease;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-password:hover {
    color: white;
}

/* Button Acceder */
.btn-login {
    width: 100%;
    padding: 1.15rem;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 1.25rem;
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
}

.btn-login::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: all 0.6s ease;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px -5px rgba(37, 99, 235, 0.5);
    filter: brightness(1.15);
}

.btn-login:hover::before {
    left: 100%;
}

.btn-login:active {
    transform: translateY(0);
}

/* Spinner for Loading State */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

.btn-login.loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn-login.loading .spinner {
    display: block;
}

/* Back to Home Button */
.btn-back-landing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 1.15rem;
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--glass-border);
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-premium);
    margin-top: 1rem;
}

.btn-back-landing:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

.btn-back-landing:active {
    transform: translateY(0);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    margin-bottom: 2.25rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
    animation: shake 0.6s cubic-bezier(.36,.07,.19,.97) both;
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.08);
}

.alert i {
    font-size: 1.1rem;
    color: #ef4444;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* Footer in Login Card (Responsive only) */
.login-card-footer {
    display: none;
    text-align: center;
    margin-top: 2.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive adjustments for Laptop/Notebook screens */
@media (max-width: 1366px), (max-height: 850px) {
    .login-visual-panel {
        padding: 2.5rem;
    }
    
    .visual-title {
        font-size: 2.3rem;
    }
    
    .visual-description {
        font-size: 0.95rem;
        margin-bottom: 2rem;
    }
    
    .features-grid-custom {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .glass-feature-card {
        flex-direction: row;
        align-items: center;
        padding: 0.85rem 1.25rem;
        gap: 16px;
        border-radius: 16px;
    }
    
    .glass-feature-card-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
        border-radius: 10px;
        margin-bottom: 0;
    }
    
    .glass-feature-card h3 {
        font-size: 0.95rem;
        margin: 0;
    }
    
    .glass-feature-card p {
        display: none;
    }
}

@media (max-height: 850px) {
    .login-card {
        padding: 2.25rem 2rem;
    }
    
    .login-header {
        margin-bottom: 1.5rem;
    }
    
    .school-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 0.75rem;
    }
    
    .app-name {
        font-size: 1.6rem;
    }
    
    .role-tabs {
        margin-bottom: 1.5rem;
    }
}

/* Responsive Rules */
@media (max-width: 1024px) {
    .login-visual-panel {
        display: none;
    }
    
    .login-form-panel {
        flex: 1;
        background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.1) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(124, 58, 237, 0.06) 0%, transparent 40%),
                    #050811;
        position: relative;
        overflow: hidden;
    }
    
    /* Show Fondo.webp as blurred full-screen background on mobile */
    .login-form-panel::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: url('../img/Fondo.webp') no-repeat center center;
        background-size: cover;
        opacity: 0.18;
        filter: blur(10px);
        -webkit-filter: blur(10px);
        pointer-events: none;
        z-index: -1;
    }
    
    .login-card-footer {
        display: block;
    }
}

@media (max-width: 480px) {
    .login-form-panel {
        padding: 1.5rem 1rem;
    }

    .login-card {
        padding: 2.25rem 1.25rem;
        border-radius: 24px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
        border-color: rgba(255, 255, 255, 0.08);
        background: rgba(15, 20, 35, 0.85);
    }

    .app-name {
        font-size: 1.6rem;
    }

    .school-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 1rem;
    }
    
    .form-control {
        font-size: 0.9rem;
        padding: 1.45rem 2.5rem 0.55rem 3rem;
    }
    
    .input-container label {
        left: 3rem;
        font-size: 0.9rem;
    }
    
    .form-control:focus ~ label,
    .form-control:not(:placeholder-shown) ~ label {
        top: 10px;
        left: 3rem;
        font-size: 0.68rem;
    }
    
    .input-container > i:first-of-type {
        left: 1.1rem;
    }
    
    .role-tabs {
        margin-bottom: 1.75rem;
    }
}

@media (max-width: 380px) {
    .role-tab {
        padding: 8px 10px;
        font-size: 0.8rem;
        gap: 4px;
    }
    
    .role-tab i {
        font-size: 0.85rem;
    }
    
    .login-card {
        padding: 2rem 1rem;
    }
}
