/* ============================================
   ImobiSISMAX - Tela de Login
   Design premium Liquid Glass
   ============================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Background com efeito de profundidade */
.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 40%, rgba(195, 0, 1, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 70% 60%, rgba(242, 158, 159, 0.06) 0%, transparent 50%),
                radial-gradient(circle at 50% 50%, rgba(27, 13, 0, 0.04) 0%, transparent 50%);
    animation: bgFloat 20s ease-in-out infinite;
    z-index: 0;
}

@keyframes bgFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, -2%) rotate(1deg); }
    50% { transform: translate(-1%, 1%) rotate(-0.5deg); }
    75% { transform: translate(1%, 2%) rotate(0.5deg); }
}

.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}

/* Card principal do login */
.login-card {
    background: var(--bg-glass-strong);
    backdrop-filter: blur(var(--blur-glass-strong));
    -webkit-backdrop-filter: blur(var(--blur-glass-strong));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glass-lg);
    padding: 40px;
    animation: cardAppear 0.6s ease;
}

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

/* Logo e título */
.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 260px;
    max-width: 100%;
    margin: 0 auto 16px;
    line-height: 0;
}

.login-logo img {
    display: block;
    width: 100%;
    height: auto;
}

.login-logo .login-brand-on-dark,
.dark .login-logo .login-brand-on-light {
    display: none;
}

.dark .login-logo .login-brand-on-dark {
    display: block;
}

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

/* Campos do formulário */
.login-form .input-group {
    margin-bottom: 18px;
}

.login-form .input-glass {
    padding: 14px 16px;
    font-size: 15px;
}

/* Dica sobre campo empresa_id */
.login-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.login-hint svg {
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
    flex-shrink: 0;
}

/* Botão de login */
.login-btn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 8px;
}

.login-btn .btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
}

/* Toggle senha visível */
.password-wrapper {
    position: relative;
}

.password-wrapper .input-glass {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    transition: var(--transition);
}

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

/* Mensagem de erro do login */
.login-error {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.login-error.show {
    display: flex;
}

.login-otp {
    --otp-accent: var(--accent-text, var(--accent));
    --otp-tint: color-mix(in srgb, var(--accent) 8%, var(--bg-surface));
    display: grid;
    gap: 14px;
    padding: clamp(14px, 4vw, 22px);
    border: 1px solid var(--border-glass-strong, var(--border-glass));
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg, 16px);
    background: linear-gradient(155deg, var(--otp-tint), var(--bg-surface) 45%);
    box-shadow: var(--shadow-glass);
}

.login-otp-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.login-otp-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    color: var(--otp-accent);
    background: var(--accent-light);
}

.login-otp-header h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}

.login-otp-header p,
.login-otp-trust-copy small {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

.login-otp .login-otp-input {
    margin: 0;
}

.login-otp #device-code {
    min-height: 58px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass-strong, var(--border-glass));
    border-radius: 12px;
    text-align: center;
    font: 700 clamp(23px, 6vw, 30px)/1.15 Consolas, "Courier New", monospace;
    letter-spacing: .25em;
    text-indent: .25em;
    font-variant-numeric: tabular-nums;
}

.login-otp #device-code::placeholder {
    color: var(--text-muted);
    opacity: .65;
}

.login-otp #device-code:focus {
    border-color: var(--otp-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.login-otp-trust {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    background: var(--bg-surface);
    cursor: pointer;
}

.login-otp-trust-copy {
    display: grid;
    gap: 2px;
    font-size: 13px;
    line-height: 1.35;
}

.login-otp .toggle {
    flex-shrink: 0;
}

.login-otp .login-btn {
    margin: 0;
    min-height: 46px;
}

.login-otp-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 2px 6px;
}

.login-otp-actions .btn {
    min-height: 40px;
    padding-inline: 6px;
    white-space: normal;
    text-align: left;
    font-size: 12px;
}

.login-otp-actions #device-back {
    color: var(--text-muted);
}

.login-otp-actions #device-resend {
    color: var(--otp-accent);
    font-weight: 600;
}

/* Footer do login */
.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-glass);
}

.login-footer p {
    font-size: 12px;
    color: var(--text-muted);
}

.login-legal-links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 12px;
}

.login-legal-links a {
    color: var(--primary-text, var(--primary));
    font-weight: 600;
    text-decoration: none;
}

.login-legal-links a:hover {
    text-decoration: underline;
}

.login-legal-links span {
    color: var(--text-muted);
}

/* Toggle tema no login */
.login-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
}

/* Responsivo */
.login-space { display: none; }

@media (min-width: 992px) {
    .login-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 0;
    }
    .login-wrapper::before { display: none; }
    .login-container { justify-self: center; margin-block: 64px; }
    .login-card {
        padding: 28px;
        background: transparent;
        border: 0;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        animation: none;
    }
    .login-space {
        position: relative;
        container-type: size;
        display: grid;
        place-items: center;
        align-self: stretch;
        overflow: hidden;
        isolation: isolate;
        background: #111827 url("../../img/login-espaco.webp") center / cover;
        color: white;
    }
    .login-theo-track {
        position: absolute;
        z-index: 1;
        inset: 24px;
        pointer-events: none;
    }
    .login-theo {
        position: absolute;
        width: var(--theo-size, 22%);
        max-width: 55%;
        max-height: 90%;
        aspect-ratio: 504 / 669;
        left: var(--theo-x, 10%);
        top: var(--theo-y, 12%);
        transform: translate(calc(0% - var(--theo-x, 10%)), calc(0% - var(--theo-y, 12%)));
    }
    .login-theo::before {
        content: "";
        display: block;
        height: 100%;
        background: url("../../img/login-theo.png") center / contain no-repeat;
        animation: login-theo-float 8s ease-in-out infinite;
    }
    .login-launch {
        position: relative;
        z-index: 0;
        text-align: center;
        text-transform: uppercase;
        text-shadow: 0 2px 8px #000;
        transition: transform 4s ease;
    }
    .login-launch p { margin: 0 0 24px; }
    .login-rocket {
        position: relative;
        z-index: 1;
        width: 230px;
        aspect-ratio: 512 / 513;
        background: url("../../img/login-foguete.svg") center / contain no-repeat;
    }
    .login-exhaust {
        position: absolute;
        left: 50%;
        bottom: 46px;
        transform: scaleY(-1) translateX(-40px);
        opacity: 0;
        transition: opacity 250ms ease;
    }
    .login-flame { position: relative; }
    .login-flame span {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 80px;
        aspect-ratio: 1;
        border-radius: 50% 0 50% 50%;
        transform: rotate(-45deg);
        color: orangered;
        background: currentColor;
        box-shadow: 0 0 10px 5px currentColor;
    }
    .login-flame span:nth-child(2) { left: 10px; width: 60px; color: orange; box-shadow: 0 0 12px 6px currentColor; }
    .login-flame span:nth-child(3) { left: 18px; width: 45px; color: gold; box-shadow: 0 0 9px 4px currentColor; }
    .login-flame span:nth-child(4) { left: 22px; width: 35px; color: lightyellow; box-shadow: 0 0 9px 4px currentColor; }
    @keyframes login-exhaust-flicker {
        0% { transform: rotate(-1deg); }
        20% { transform: rotate(3deg) scaleY(1.05); }
        60% { transform: rotate(1deg); }
        80% { transform: rotate(-1deg) scaleY(.9); }
        100% { transform: rotate(4deg); }
    }
    .login-space.is-launching .login-launch {
        transform: translateY(calc(-50vh - 100%));
        transform: translateY(calc(-50cqh - 100%));
        transition: transform 1100ms cubic-bezier(.5,0,.8,.65);
    }
    .login-space.is-launching .login-exhaust { opacity: 1; }
    .login-space.is-launching .login-flame { animation: login-exhaust-flicker 3ms ease-in infinite; }
    @keyframes login-theo-float {
        0%, 100% { transform: translate(0,0) rotate(0); }
        35% { transform: translate(12px,-16px) rotate(4deg); }
        70% { transform: translate(-10px,12px) rotate(-3deg); }
    }
}
@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
    .login-theo::before { animation: none; }
    .login-space.is-launching .login-flame { animation: none; }
    .login-space .login-launch { transition: none; transform: none; }
}

@media (max-width: 480px) {
    .login-card {
        padding: 28px 24px;
    }

}
