/* ============================================
   DocSuite - Login Profesional
   Diseño moderno para aplicación médica
   ============================================ */

/* Variables CSS */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #10b981;
    --accent-color: #06b6d4;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --bg-light: #f8fafc;
    --white: #ffffff;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Reset y Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

body.login-page {
    background: var(--bg-light);
    overflow-x: hidden;
}

/* Contenedor Principal */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: row;
}

/* Panel Izquierdo - Ilustración */
.login-illustration {
    flex: 1;
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
}

.login-illustration::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse-bg 15s ease-in-out infinite;
}

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

/* Formas decorativas */
.login-illustration .shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    background: var(--white);
}

.login-illustration .shape-1 {
    width: 300px;
    height: 300px;
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.login-illustration .shape-2 {
    width: 200px;
    height: 200px;
    bottom: 100px;
    left: -50px;
    animation: float 6s ease-in-out infinite reverse;
}

.login-illustration .shape-3 {
    width: 150px;
    height: 150px;
    bottom: -50px;
    right: 20%;
    animation: float 10s ease-in-out infinite;
}

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

/* Contenido del panel izquierdo */
.illustration-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: var(--white);
    max-width: 500px;
}

.illustration-icon {
    width: 180px;
    height: 180px;
    margin: 0 auto 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 30px rgba(255,255,255,0.2); }
    50% { box-shadow: 0 0 50px rgba(255,255,255,0.4); }
}

.illustration-icon svg {
    width: 80px;
    height: 80px;
    fill: var(--white);
}

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

.illustration-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.7;
}

/* Features list */
.features-list {
    margin-top: 50px;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    backdrop-filter: blur(5px);
    transition: var(--transition);
}

.feature-item:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(10px);
}

.feature-item svg {
    width: 24px;
    height: 24px;
    fill: var(--white);
    flex-shrink: 0;
}

.feature-item span {
    font-size: 0.95rem;
}

/* Panel Derecho - Formulario */
.login-form-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    background: var(--white);
    position: relative;
}

/* Logo del tenant */
.tenant-badge {
    position: absolute;
    top: 30px;
    right: 30px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card del formulario */
.login-card {
    width: 100%;
    max-width: 440px;
}

/* Logo */
.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo img {
    max-height: 70px;
    width: auto;
    transition: var(--transition);
}

.login-logo img:hover {
    transform: scale(1.05);
}

/* Títulos */
.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Formulario */
.login-form {
    width: 100%;
}

/* Grupo de inputs */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

/* Input con icono */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--text-light);
    pointer-events: none;
    transition: var(--transition);
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-size: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    background: var(--bg-light);
    color: var(--text-dark);
    transition: var(--transition);
    outline: none;
}

.input-wrapper input::placeholder {
    color: var(--text-light);
}

.input-wrapper input:hover {
    border-color: #cbd5e1;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper input:not(:placeholder-shown) + .input-icon {
    color: var(--primary-color);
}

/* Toggle password */
.toggle-password {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 5px;
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--primary-color);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* Error state */
.input-wrapper.has-error input {
    border-color: var(--error-color);
    background: #fef2f2;
}

.input-wrapper.has-error input:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--error-color);
}

.error-message svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Remember & Forgot */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.remember-me span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

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

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

/* Botón Submit */
.btn-login {
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    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: var(--shadow-lg);
}

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

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

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner de carga */
.btn-login .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

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

.btn-login.loading .btn-text {
    opacity: 0.8;
}

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

/* Divider */
.divider {
    display: flex;
    align-items: center;
    margin: 30px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.divider span {
    padding: 0 16px;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Registro */
.register-link {
    text-align: center;
    padding: 20px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    margin-top: 20px;
}

.register-link p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.register-link a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

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

/* Footer */
.login-footer {
    margin-top: 50px;
    text-align: center;
}

.login-footer .legal-links {
    list-style: none;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 15px;
}

.login-footer .legal-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: var(--transition);
}

.login-footer .legal-links a:hover {
    color: var(--primary-color);
}

.login-footer .copyright {
    color: var(--text-light);
    font-size: 0.8rem;
}

.login-footer .copyright a {
    color: var(--primary-color);
    text-decoration: none;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
    .login-illustration {
        padding: 40px;
    }
    
    .login-form-panel {
        padding: 40px;
    }
    
    .illustration-content h2 {
        font-size: 2rem;
    }
}

@media (max-width: 992px) {
    .login-wrapper {
        flex-direction: column;
    }
    
    .login-illustration {
        padding: 40px 30px;
        min-height: auto;
    }
    
    .illustration-icon {
        width: 120px;
        height: 120px;
        margin-bottom: 25px;
    }
    
    .illustration-icon svg {
        width: 50px;
        height: 50px;
    }
    
    .illustration-content h2 {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }
    
    .illustration-content p {
        font-size: 0.95rem;
    }
    
    .features-list {
        display: none;
    }
    
    .login-form-panel {
        padding: 40px 30px;
    }
    
    .tenant-badge {
        top: 15px;
        right: 15px;
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .login-illustration {
        padding: 30px 20px;
    }
    
    .illustration-icon {
        width: 100px;
        height: 100px;
    }
    
    .illustration-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .illustration-content h2 {
        font-size: 1.3rem;
    }
    
    .login-form-panel {
        padding: 30px 20px;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .form-options {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .login-footer .legal-links {
        flex-direction: column;
        gap: 10px;
    }
}

/* ============================================
   Dark Mode (opcional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    body.login-page.dark-mode {
        --bg-light: #0f172a;
        --white: #1e293b;
        --text-dark: #f1f5f9;
        --text-muted: #94a3b8;
        --text-light: #64748b;
    }
    
    body.login-page.dark-mode .login-form-panel {
        background: #1e293b;
    }
    
    body.login-page.dark-mode .input-wrapper input {
        border-color: #334155;
        background: #0f172a;
    }
}

/* ============================================
   Animaciones de entrada
   ============================================ */

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

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.login-card {
    animation: fadeInUp 0.6s ease-out;
}

.illustration-content {
    animation: fadeInLeft 0.6s ease-out;
}

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

.feature-item {
    animation: fadeInLeft 0.6s ease-out backwards;
}

/* ============================================
   Alertas de sesión
   ============================================ */

.alert-session {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.alert-session svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-session.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-session.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-session.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}
