/* ========================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
   ======================================== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #60a5fa;
    --secondary-color: #0ea5e9;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-light: #f8fafc;
    --bg-dark: #0f172a;
    --card-bg: #ffffff;
    --card-bg-dark: #1e293b;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    --border-color: #e2e8f0;
    --border-focus: #2563eb;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Oscuro Automático */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #0f172a;
        --card-bg: #1e293b;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --border-color: #334155;
    }
}

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    overflow: hidden;
}

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */
.login-container {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.login-panel {
    position: relative;
    min-height: 0;
}

/* ========================================
   PANEL IZQUIERDO - FORMULARIO
   ======================================== */
.login-panel-form {
    width: 38%;
    min-width: 380px;
    background: linear-gradient(135deg, var(--bg-light) 0%, #f1f5f9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2.5rem;
    position: relative;
    overflow: hidden;
}

.login-panel-form::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.03) 0%, transparent 70%);
    pointer-events: none;
}

.form-wrapper {
    width: 100%;
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.logo-container {
    text-align: center;
    margin-bottom: 1.15rem;
}

.logo {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 6px rgba(37, 99, 235, 0.2));
}

.brand-title {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.welcome-text {
    text-align: center;
    margin-bottom: 1.5rem;
}

.welcome-text h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-text p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ========================================
   FORMULARIO Y INPUTS
   ======================================== */
.login-form {
    background: var(--card-bg);
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.form-group-custom {
    margin-bottom: 1.25rem;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}

.form-label i {
    color: var(--primary-color);
    font-size: 0.95rem;
}

.input-wrapper {
    position: relative;
}

.form-control-custom {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    border: 2px solid #D1D5DB;
    border-radius: var(--radius-md);
    background: var(--card-bg);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.form-control-custom::placeholder {
    color: var(--text-light);
}

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

.password-input {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.forgot-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.forgot-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.btn-login {
    width: 100%;
    padding: 0.7rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: var(--transition);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
    position: relative;
    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.2), transparent);
    transition: 0.5s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.4);
}

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

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

.btn-login i {
    transition: transform 0.3s;
}

.btn-login:hover i {
    transform: translateX(4px);
}

/* ========================================
   PANEL DERECHO - IMAGEN
   ======================================== */
.login-panel-image {
    width: 62%;
    background: url("../img/presentacion.webp") center/cover no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.85) 0%, rgba(30, 64, 175, 0.9) 100%);
}

.image-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: white;
    padding: 2rem;
    max-width: 650px;
}

.brand-showcase {
    animation: fadeInUp 1s ease-out;
}

.logo-large {
    width: 260px;
    height: 260px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.3));
    will-change: transform; 
}

.brand-showcase h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.brand-showcase p {
    font-size: 1.25rem;
    opacity: 0.9;
    font-weight: 300;
}

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

/* ========================================
   FOOTER
   ======================================== */
.login-footer {
    background: #E5E7EB;
    color: #1F2937;
    text-align: center;
    padding: 7px 20px;
    font-size: 0.85rem;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
    font-weight: 500;
}

.login-footer p {
    margin: 0;
}

/* ========================================
   ALERTAS
   ======================================== */
.alert {
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideIn 0.3s ease-out;
}

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

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border-left: 4px solid var(--warning-color);
}

/* ========================================
   RESPONSIVE DESIGN - TABLETS
   ======================================== */
@media (max-width: 1024px) {
    .login-panel-form {
        width: 42%;
        min-width: 350px;
        padding: 1.5rem;
    }
    
    .login-panel-image {
        width: 58%;
    }
    
    .logo-large {
        width: 220px;
        height: 220px;
    }
    
    .brand-showcase h2 {
        font-size: 2rem;
    }
}

/* ========================================
   RESPONSIVE DESIGN - MÓVILES (SIN SCROLL)
   ======================================== */
@media (max-width: 768px) {
    html, body {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .login-container {
        flex-direction: column;
        min-height: 0;
        flex: 1;
    }
    
    .login-panel-form {
        width: 100%;
        min-width: 100%;
        padding: 0.75rem 1.25rem;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }
    
    .login-panel-image {
        display: none; 
    }
    
    .form-wrapper {
        max-width: 100%;
    }
    
    /* Solución para móviles: Tamaño dinámico basado en el ancho (vw) 
       Se ve grande pero sin romper el límite de altura */
    .logo {
        width: 30vw; 
        max-width: 150px;
        height: auto;
    }
    
    .brand-title {
        font-size: 1.5rem;
    }
    
    .welcome-text h2 {
        font-size: 1.25rem;
    }
    
    .login-form {
        padding: 3rem 2rem;
        box-shadow: var(--shadow-lg);
    }

    .form-control-custom {
        padding: 0.55rem;
        font-size: 16px; 
        min-height: 40px; 
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.65rem;
    }

    .form-group-custom {
        margin-bottom: 1.5rem;
    }
    
    .btn-login {
        padding: 0.6rem;
        font-size: 0.95rem;
        min-height: 40px;
    }
}

/* ========================================
   MÓVILES PEQUEÑOS (Ej: Nokia G20)
   ======================================== */
@media (max-width: 480px) {
    .login-panel-form {
        padding: 0.5rem 1rem;
    }
    
    /* En dispositivos muy estrechos, el logo usa un 25% del ancho
       para seguir viéndose grande pero sin provocar scroll vertical */
    .logo {
        width: 25vw;
        max-width: 120px;
        height: auto;
    }
    
    .brand-title {
        font-size: 1.25rem;
    }
    
    .welcome-text h2 {
        font-size: 1rem;
    }
    
    .welcome-text p {
        font-size: 0.8rem;
    }
    
    .login-form {
        padding: 3rem 2rem;
        border-radius: var(--radius-lg);
    }
    
    .form-group-custom {
        margin-bottom: 1.5rem;
    }
    
    .btn-login {
        padding: 0.55rem;
    }
}

/* ========================================
   UTILIDADES ADICIONALES
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 8px;
}

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

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

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