/*
 * Sistema de Gestión Documental (Login styles)
 * Author: Miguel Ramirez (https://github.com/NixSpawn)
 * Date: 20/08/2025
 */

/* Contenedor principal */
.modern-login-container {
    min-height: 100vh;
    background: oklch(var(--background));
}

/* Mobile Header */
.mobile-header {
    display: block;
    height: 10rem;
    position: relative;
    overflow: hidden;
}

.mobile-header-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    /* La imagen se define inline en el JSP usando ${staticResourcesURL} */
}

.mobile-header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, oklch(var(--primary) / 0.9) 0%, oklch(var(--primary) / 0.85) 50%, oklch(var(--primary) / 0.8) 100%);
}

.mobile-header-content {
    position: relative;
    z-index: 10;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-header-text {
    text-align: center;
    color: oklch(var(--primary-foreground));
    padding: 0 1rem;
}

.mobile-header-text h1 {
    font-size: 1.25rem;
    line-height: 1.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.mobile-header-text p {
    font-size: 0.875rem;
    line-height: 1.25rem;
    opacity: 0.9;
}

.mobile-header-divider {
    margin-top: 0.75rem;
    display: flex;
    justify-content: center;
}

.mobile-header-divider::after {
    content: '';
    width: 3rem;
    height: 0.25rem;
    background-color: oklch(var(--primary-foreground));
    border-radius: 9999px;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: row-reverse;
    height: 100vh;
}

/* Login Panel */
.login-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 28rem;
    background-color: oklch(var(--card));
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2rem;
    border: 1px solid oklch(var(--border));
}

/* Form Header */
.form-header-modern {
    text-align: center;
    padding: 0 1rem;
}

.modern-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
}

.logo-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.modern-title {
    font-size: 1.5rem;
    line-height: 2rem;
    margin-bottom: 0.5rem;
    color: oklch(var(--foreground));
    font-weight: 600;
}

.modern-subtitle {
    color: oklch(var(--muted-foreground));
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-transform: uppercase;
}

/* Form Fields */
.modern-field {
    margin-bottom: 1.5rem;
}

/* Floating Input Container */
.floating-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Floating Input */
.floating-input {
    width: 100%;
    padding: 1rem 4rem 0.5rem 1rem;
    border: 2px solid oklch(var(--border));
    border-radius: 0.75rem;
    color: oklch(var(--foreground));
    font-size: 0.75rem;
    line-height: 1.5;
    transition: all 0.3s ease;
    outline: none;
}

.floating-input:focus {
    border-color: oklch(var(--ring));
    background-color: oklch(var(--background));
}

.floating-input:focus + .floating-label{
    color: oklch(var(--ring));
}

.floating-input.with-toggle {
    padding-right: 4rem;
}

/* Floating Label */
.floating-label {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 0.5rem;
    color: oklch(var(--muted-foreground));
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
}

/* Label icon */
.floating-label .label-icon {
    font-size: 0.75rem;
}

/* Floating label cuando el input tiene contenido o está enfocado */
.floating-input:focus + .floating-label,
.floating-input:not(:placeholder-shown) + .floating-label,
.floating-input[value]:not([value=""]) + .floating-label {
    top: 0;
    left: 1rem;
    transform: translateY(-50%);
    font-size: 0.75rem;
    background-color: oklch(var(--background));
    border-radius: 0.25rem;
}

/* Para inputs readonly (como dependencia) */
.floating-input[readonly]:not([value=""]) + .floating-label {
    top: 0;
    left: 2rem;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: oklch(var(--muted-foreground));
    background-color: oklch(var(--background));
    border-radius: 0.25rem;
}

/* Input icon en la esquina izquierda */
.floating-input-wrapper::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    z-index: 2;
    pointer-events: none;
}

/* Password Toggle */
.toggle-password-modern {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: oklch(var(--muted-foreground));
    padding: 0.5rem;
    transition: color 0.2s ease;
    z-index: 2;
}

.toggle-password-modern:hover {
    color: oklch(var(--foreground));
}

.toggle-password-modern i {
    font-size: 1rem;
}

/* Dependency Button */
.modern-dependency-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: oklch(var(--muted));
    border: 1px solid oklch(var(--border));
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    color: oklch(var(--muted-foreground));
    transition: all 0.2s ease;
    z-index: 2;
}

.modern-dependency-btn:hover {
    background-color: oklch(var(--muted) / 0.8);
    color: oklch(var(--foreground));
}

.modern-dependency-btn i {
    font-size: 1rem;
}

/* Labels estáticos (como el de Turnstile) */
.modern-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: oklch(var(--foreground));
    font-size: 0.75rem;
    line-height: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.label-icon {
    font-size: 1rem;
}

/* Captcha Container */
.captcha-container {
    display: flex;
    gap: 0.5rem;
}

.captcha-container .modern-input {
    flex: 1;
    padding-left: 0.75rem;
}

.modern-refresh-btn {
    height: 3rem;
    padding: 0 0.75rem;
    background: none;
    border: 1px solid oklch(var(--border));
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: oklch(var(--muted-foreground));
}

.modern-refresh-btn:hover {
    background-color: oklch(var(--muted));
}

.modern-refresh-btn i {
    font-size: 1rem;
}

.captcha-display {
    border: 1px solid oklch(var(--border));
    border-radius: 0.75rem;
    padding: 0.1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.captcha-display img {
    border-radius: 0.5rem;
    max-width: 100%;
    height: auto;
    display: block;
}

/* Submit Button */
.modern-submit-btn {
    width: 100%;
    height: 3rem;
    background-color: oklch(var(--primary));
    color: oklch(var(--primary-foreground));
    border: none;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    line-height: 1.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.modern-submit-btn:hover {
    background-color: oklch(var(--primary) / 0.9);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(-1px);
}

.modern-submit-btn:active {
    transform: translateY(0);
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.loading-icon {
    font-size: 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Contenedor principal del error de login */
.login-error-container {
    margin: 15px 0;
    padding: 0;
    animation: login-error-slideIn 0.4s ease-out;
}

/* Alerta principal */
.login-error-alert {
    background: oklch(var(--destructive) / 0.1);
    border: 1px solid oklch(var(--destructive) / 0.3);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 12px oklch(var(--destructive) / 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.login-error-alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(180deg, oklch(var(--destructive) / 0.8) 0%, oklch(var(--destructive) / 0.8) 100%);
}

/* Icono principal */
.login-error-icon {
    flex-shrink: 0;
    color: oklch(var(--destructive));
    font-size: 20px;
    margin-top: 2px;
}

/* Contenido del error */
.login-error-content {
    flex: 1;
    min-width: 0;
}

/* Item individual de error */
.login-error-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.login-error-item:last-child {
    margin-bottom: 0;
}

/* Bullet de error */
.login-error-bullet {
    color: oklch(var(--destructive));
    font-size: 12px;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Texto del error */
.login-error-text {
    color: oklch(var(--destructive));
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

/* Acciones del error */
.login-error-actions {
    position: absolute;
    display: flex;
    top: 5px;
    right: 5px;
}

/* Botón de cerrar */
.login-error-dismiss {
    background: transparent;
    border: none;
    color: oklch(var(--destructive));
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.login-error-dismiss:hover {
    background: oklch(var(--destructive) / 0.1);
    color: oklch(var(--destructive) / 0.8);
    transform: scale(1.1);
}

.login-error-dismiss:active {
    transform: scale(0.95);
}

/* Animaciones */
@keyframes login-error-slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 480px) {
    .login-error-alert {
        padding: 14px;
        gap: 10px;
    }

    .login-error-text {
        font-size: 12px;
    }

    .login-error-icon {
        font-size: 18px;
    }
}

/* Estado de hover para toda la alerta */
.login-error-alert:hover {
    box-shadow: 0 6px 16px oklch(var(--destructive) / 0.2);
    transition: box-shadow 0.3s ease;
}

/* Variante para errores múltiples */
.login-error-messages .login-error-item:not(:last-child) {
    padding-bottom: 6px;
    border-bottom: 1px solid oklch(var(--destructive) / 0.1);
    margin-bottom: 8px;
}

/* Footer */
.modern-footer {
    padding-top: 1rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* Version Info Styles */
.version-info {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid oklch(var(--border));
}

.version-text {
    color: oklch(var(--muted-foreground));
    font-size: 0.75rem;
    line-height: 1rem;
    font-weight: 400;
}

/* Responsive para versión */
@media (max-width: 480px) {
    .version-info {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }

    .version-text {
        font-size: 0.7rem;
    }
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: oklch(var(--muted-foreground));
    text-decoration: none;
    font-size: 0.75rem;
    line-height: 1.25rem;
    transition: all 0.2s ease;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.footer-link:hover {
    color: oklch(var(--primary));
    background-color: oklch(var(--muted));
}

.footer-icon {
    font-size: 0.75rem;
}

/* Carousel Panel (Desktop only) */
.carousel-panel {
    display: none;
    flex: 1;
    min-height: 100vh;
    padding: 1.5rem;
}

.carousel-container {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    /* Fallback background si no hay imágenes */
    background: linear-gradient(135deg, oklch(var(--primary)) 0%, oklch(var(--primary) / 0.9) 100%);
}

.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.carousel-slide.active {
    opacity: 1;
}

.slide-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: all 1s ease-in-out;
}

.slide-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, oklch(var(--primary) / 0.6) 0%, oklch(var(--primary) / 0.5) 50%, rgba(0, 0, 0, 0.4) 100%);
}

.slide-content {
    position: absolute;
    bottom: 5rem;
    left: 2rem;
    right: 2rem;
    z-index: 10;
    color: oklch(var(--primary-foreground));
    text-align: end;
}

.slide-icon {
    margin-bottom: 1.5rem;
}

.slide-icon i {
    font-size: 3rem;
    color: oklch(var(--primary-foreground));
}

.slide-content h2 {
    margin-bottom: 1rem;
    font-size: 1.875rem;
    line-height: 2.25rem;
    font-weight: 600;
}

.slide-content p {
    display: inline-block;
    font-size: 1.125rem;
    line-height: 1.75rem;
    opacity: 0.9;
    max-width: 32rem;
}

/* Carousel Progress */
.carousel-progress {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 0.5rem;
}

.progress-bar {
    width: 0.5rem;
    height: 0.5rem;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
}

.progress-bar:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.progress-bar.active {
    background-color: rgba(255, 255, 255, 0.4);
    width: 50px;
}

.progress-bar.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: oklch(var(--primary-foreground));
    border-radius: 9999px;
    animation: progress 6s linear infinite;
}

@keyframes progress {
    from { width: 0%; }
    to { width: 100%; }
}

/* Mobile Bottom Gradient */
.mobile-bottom-gradient {
    display: block;
    height: 5rem;
    background: linear-gradient(to top, oklch(var(--muted)), transparent);
}

/* Desktop Styles */
@media (min-width: 1024px) {
    .mobile-header {
        display: none;
    }

    .main-content {
        min-height: 100vh;
    }

    .login-card {
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    }

    .carousel-panel {
        display: flex;
    }

    .mobile-bottom-gradient {
        display: none;
    }
}

/* Tablet Styles */
@media (max-width: 1023px) {
    .login-panel {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }

    .login-card {
        margin: 1rem;
        border-radius: 1rem;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    }

    .modern-logo {
        margin: 0 0 1rem 0;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Styles */
@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
    }

    .login-card {
        padding: 1.5rem;
        border-radius: 1rem;
        margin: 0.5rem;
    }

    .modern-title {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }

    .modern-subtitle {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    .floating-input {
        height: 3rem;
        padding: 1rem 2.5rem 0.5rem 1rem;
        font-size: 0.65rem;
    }

    .floating-input.with-toggle {
        padding-right: 3.5rem;
    }

    .floating-label {
        left: 1rem;
        font-size: 0.65rem;
    }

    .floating-input:focus + .floating-label,
    .floating-input:not(:placeholder-shown) + .floating-label,
    .floating-input[value]:not([value=""]) + .floating-label,
    .floating-input[readonly]:not([value=""]) + .floating-label {
        left: 1rem;
        font-size: 0.65rem;
    }

    .modern-dependency-btn {
        padding: 0.5rem 0.75rem;
    }

    .toggle-password-modern {
        right: 0.75rem;
        padding: 0.25rem;
    }

    .modern-submit-btn {
        height: 2.5rem;
        font-size: 0.95rem;
    }

    .footer-grid {
        gap: 0.5rem;
    }

    .footer-link span {
        font-size: 0.8rem;
    }
}

/* Estilos adicionales para Cloudflare Turnstile */

/* Contenedor de Turnstile */
.turnstile-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0;
    min-height: 65px;
}

/* Widget de Turnstile */
.cf-turnstile {
    margin: 0 auto;
}

/* Responsive para Turnstile */
@media (max-width: 768px) {
    .turnstile-container {
        margin: 8px 0;
        min-height: 60px;
    }

    .cf-turnstile {
        transform: scale(0.8);
        transform-origin: center;
    }
}

@media (max-width: 480px) {
    .cf-turnstile {
        transform: scale(0.7);
        transform-origin: center;
    }
}

/* Mensaje de error específico para Turnstile */
.turnstile-error {
    font-size: 14px;
    line-height: 1.4;
    border-radius: 6px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Estado de carga para Turnstile */
.turnstile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 65px;
    color: oklch(var(--muted-foreground));
    font-size: 14px;
}

.turnstile-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid oklch(var(--muted));
    border-top: 2px solid oklch(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

/* Ajustes para el campo moderno */
.modern-field #divTurnstile {
    margin-top: 5px;
}

.modern-field .turnstile-container {
    background: oklch(var(--muted) / 0.5);
    border: 1px solid oklch(var(--border));
    border-radius: 8px;
    padding: 10px;
    transition: all 0.3s ease;
}

.modern-field .turnstile-container:hover {
    border-color: oklch(var(--primary));
    box-shadow: 0 0 0 3px oklch(var(--primary) / 0.1);
}

/* Tema oscuro para Turnstile (opcional) */
.dark-theme .turnstile-container {
    background: oklch(var(--muted));
    border-color: oklch(var(--border));
}

.dark-theme .cf-turnstile {
    filter: invert(1) hue-rotate(180deg);
}

/* Integración con el diseño existente */
.modern-field .modern-label i.fa-shield-halved {
    color: oklch(var(--chart-2));
}

/* Fallback cuando Turnstile no está disponible */
.turnstile-fallback {
    text-align: center;
    padding: 15px;
    background: oklch(var(--muted) / 0.3);
    border: 1px solid oklch(var(--border));
    border-radius: 6px;
    color: oklch(var(--muted-foreground));
    font-size: 14px;
}

.turnstile-fallback i {
    margin-right: 8px;
    color: oklch(var(--chart-4));
}

/* ==============================================
   ESTILOS PARA TURNSTILE EN CAMBIO DE CONTRASEÑA
   Agregar a login.css o crear archivo separado
   ============================================== */

/* Contenedor principal del widget Turnstile en cambio de contraseña */
.pwd-turnstile-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 75px;
    padding: 10px 0;
    background: oklch(var(--muted) / 0.5);
    border-radius: 8px;
    border: 1px solid oklch(var(--border));
    margin-top: 5px;
}

/* Widget de Turnstile */
#turnstile-widget-changepwd {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 65px;
    min-width: 300px;
}

/* Asegurar que el iframe de Turnstile tenga el tamaño correcto */
#turnstile-widget-changepwd iframe {
    max-width: 100% !important;
    border-radius: 4px;
}

/* Campo de Turnstile cuando está visible */
#divTurnstileChangePwd {
    animation: fadeIn 0.3s ease-in-out;
}

/* Animación para mostrar el campo */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .pwd-turnstile-container {
        padding: 8px 5px;
        margin: 8px 0;
    }

    #turnstile-widget-changepwd {
        min-width: 280px;
        overflow-x: auto;
    }
}

/* Estados de error para Turnstile */
.pwd-turnstile-container.error {
    border-color: oklch(var(--destructive));
}

.pwd-turnstile-container.success {
    border-color: oklch(var(--chart-2));
}

/* Estilos para el widget fallback */
.turnstile-fallback-changepwd {
    border: 2px dashed oklch(var(--destructive));
    padding: 15px;
    text-align: center;
    border-radius: 8px;
    background: oklch(var(--destructive) / 0.05);
    color: oklch(var(--destructive));
    font-size: 13px;
    min-height: 65px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.turnstile-fallback-changepwd button {
    margin-top: 8px;
    padding: 4px 12px;
    background: oklch(var(--destructive));
    color: oklch(var(--primary-foreground));
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background-color 0.2s;
}

.turnstile-fallback-changepwd button:hover {
    background: oklch(var(--destructive) / 0.9);
}

/* Asegurar que el contenedor padre esté correctamente posicionado */
.pwd-field-group {
    position: relative;
    margin-bottom: 15px;
}

/* Espacio adicional para el campo de Turnstile */
#divTurnstileChangePwd.pwd-field-group {
    margin-bottom: 20px;
}

/* Estados de carga */
.pwd-turnstile-container.loading {
    background: oklch(var(--muted));
    border-color: oklch(var(--muted-foreground));
}

.pwd-turnstile-container.loading::after {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid oklch(var(--muted-foreground));
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}