/* static/css/login.css - Login do App (PWA) - redesign 22/09/2026
 *
 * - Celular (até 599px): layout de app nativo em tela cheia. Topo azul com a
 *   logo e, por baixo, uma "folha" branca com cantos arredondados que ocupa o
 *   resto da tela (sem cartão flutuando com margens sobrando).
 * - Telas maiores: cartão centralizado, como antes, com acabamento refinado.
 * - Modal de alerta (Problemas no acesso): bottom sheet no celular, diálogo
 *   centralizado em telas maiores.
 */

:root {
    --bg-dark: #020d24;
    --bg-dark-glow: #0b1f45;
    --header-blue: linear-gradient(135deg, #0ea5e9 0%, #1d6ff2 55%, #1d4ed8 100%);
    --primary-blue: #0084ff;
    --primary-hover: #006be6;
    --primary-grad: linear-gradient(135deg, #0a95ff 0%, #0068e6 100%);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --radius-lg: 24px;
    --radius-md: 14px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    /* Remove o "flash" cinza ao tocar em botões/links no Android/iOS */
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;   /* fallback */
    min-height: 100dvh;  /* altura real da viewport no mobile */
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(900px 500px at 50% -10%, rgba(29, 111, 242, 0.35) 0%, rgba(2, 13, 36, 0) 60%),
        radial-gradient(circle at 50% 0%, var(--bg-dark-glow) 0%, var(--bg-dark) 60%);
    color: var(--text-main);
    touch-action: manipulation;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

.login-wrapper {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* ==================== CARTÃO (telas maiores) ==================== */
.login-card {
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Entrada suave (classe .card-visible aplicada via JS após o load) */
    opacity: 0;
    transform: translateY(18px) scale(0.98);
    transition: opacity 0.5s ease, transform 0.6s var(--ease-out);
}
.login-card.card-visible { opacity: 1; transform: none; }

/* ==================== TOPO AZUL ==================== */
.card-header-blue {
    position: relative;
    background: var(--header-blue);
    padding: 34px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    isolation: isolate;
}

.header-glow {
    position: absolute;
    top: -55%;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
    z-index: -1;
}

/* Anéis decorativos sutis (profundidade sem poluir) */
.header-rings {
    position: absolute;
    right: -70px;
    bottom: -90px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 28px rgba(255, 255, 255, 0.04), 0 0 0 56px rgba(255, 255, 255, 0.03);
    pointer-events: none;
    z-index: -1;
}

.logo-img {
    width: clamp(84px, 24vw, 108px);
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.18));
    animation: logo-in 0.7s var(--ease-out) both 0.1s;
}

.fallback-logo {
    color: #fff;
    font-size: 52px;
    font-style: italic;
    font-weight: 800;
    margin: 0;
    line-height: 1;
}

@keyframes logo-in {
    from { opacity: 0; transform: translateY(8px) scale(0.92); }
    to   { opacity: 1; transform: none; }
}

/* ==================== CORPO ==================== */
.card-body {
    position: relative;
    padding: 28px 28px 22px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.card-body h2 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    color: var(--text-main);
}

.subtitle {
    margin: 0 0 22px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.45;
}

#loginForm { display: flex; flex-direction: column; }

/* ==================== CAMPOS ==================== */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    height: 52px;
    padding: 0 48px 0 44px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 16px; /* 16px evita o zoom automático do iOS */
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.input-wrapper input::placeholder { color: #a8b3c2; font-weight: 400; }

.input-wrapper input:hover { border-color: #cbd5e1; }

.input-wrapper input:focus {
    background: #ffffff;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.14);
}

/* Autofill do Chrome/Android sem fundo amarelo */
.input-wrapper input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
    -webkit-text-fill-color: var(--text-main);
}

/* O ícone vem DEPOIS do input no HTML para permitir o seletor ~ no foco */
.icon-left {
    position: absolute;
    left: 14px;
    color: var(--text-soft);
    font-size: 20px;
    pointer-events: none;
    transition: color 0.2s;
}
.input-wrapper input:focus ~ .icon-left { color: var(--primary-blue); }

.input-wrapper.has-error input { border-color: var(--danger); background: #fff; }
.input-wrapper.has-error .icon-left { color: var(--danger); }

.icon-right-btn {
    position: absolute;
    right: 5px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
    padding: 0;
    transition: color 0.2s, background 0.2s, transform 0.1s;
}
.icon-right-btn:hover { color: var(--text-main); }
.icon-right-btn:active { background: #eef2f7; transform: scale(0.94); }

/* ==================== OPÇÕES ==================== */
.options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 2px 0 14px;
}

.checkbox-container {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    padding-left: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
}
.checkbox-container input { position: absolute; opacity: 0; width: 0; height: 0; }

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 21px;
    height: 21px;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.checkbox-container:hover input ~ .checkmark { border-color: var(--primary-blue); }
.checkbox-container input:checked ~ .checkmark { background: var(--primary-blue); border-color: var(--primary-blue); }
.checkbox-container input:focus-visible ~ .checkmark { box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.2); }
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5.5px;
    top: 1.5px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.checkbox-container input:checked ~ .checkmark:after { display: block; }

.forgot-password {
    min-height: 40px;
    padding: 0 2px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--primary-blue);
    cursor: pointer;
    transition: color 0.2s;
}
.forgot-password:hover { color: var(--primary-hover); text-decoration: underline; }

/* ==================== MENSAGEM DE ERRO ==================== */
.error-message {
    margin: 0;
    max-height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    opacity: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease, margin 0.25s ease;
}
.error-message:not(:empty) {
    max-height: 90px;
    padding: 10px 12px;
    margin-bottom: 14px;
    opacity: 1;
}

/* ==================== BOTÃO ENTRAR ==================== */
.login-button {
    width: 100%;
    height: 54px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-grad);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: -0.1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 24px rgba(0, 120, 240, 0.32);
    transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.login-button:hover { filter: brightness(1.05); }
.login-button:active { transform: scale(0.98); box-shadow: 0 4px 12px rgba(0, 120, 240, 0.28); }
.login-button:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.3); }
.login-button:disabled { opacity: 0.85; cursor: not-allowed; transform: none; }
.login-button #btn-arrow-icon { font-size: 20px; transition: transform 0.2s; }
.icon-right-btn .material-icons { font-size: 21px; }
.app-modal__close .material-icons { font-size: 20px; }
.app-modal__icon .material-icons { font-size: 34px; }
.login-button:hover #btn-arrow-icon { transform: translateX(3px); }
.login-button.is-success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); box-shadow: 0 10px 24px rgba(16, 185, 129, 0.3); }

.btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}
.login-button.is-loading .btn-spinner { display: inline-block; }
.login-button.is-loading #btn-arrow-icon { display: none; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ==================== RODAPÉ ==================== */
.card-footer {
    margin-top: 22px;
    font-size: 11px;
    color: var(--text-soft);
    text-align: center;
    font-weight: 500;
}

/* =====================================================================
   CELULAR: layout de app em tela cheia
   ===================================================================== */
@media (max-width: 599px) {
    body { background: #ffffff; }

    .login-wrapper {
        padding: 0;
        align-items: stretch;
    }

    .login-card {
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg-dark);
        transform: none;
    }
    .login-card.card-visible { transform: none; }

    .card-header-blue {
        flex: 0 0 auto;
        min-height: clamp(190px, 34dvh, 280px);
        padding: calc(env(safe-area-inset-top) + 28px) 20px 52px;
    }
    .logo-img { width: clamp(88px, 28vw, 120px); }

    /* "Folha" branca sobreposta ao topo azul */
    .card-body {
        flex: 1 1 auto;
        margin-top: -28px;
        border-radius: 28px 28px 0 0;
        padding: 30px 22px calc(env(safe-area-inset-bottom) + 18px);
        box-shadow: 0 -10px 30px rgba(2, 13, 36, 0.12);
        animation: sheet-up 0.6s var(--ease-out) both;
    }

    .card-body h2 { font-size: 24px; }
    .subtitle { font-size: 14.5px; margin-bottom: 24px; }

    /* Rodapé sempre no fim da tela */
    .card-footer { margin-top: auto; padding-top: 24px; }
}

@keyframes sheet-up {
    from { transform: translateY(40px); opacity: 0.6; }
    to   { transform: none; opacity: 1; }
}

/* Celulares bem estreitos (ex: iPhone SE / Android 320-360px) */
@media (max-width: 360px) {
    .card-body { padding-left: 18px; padding-right: 18px; }
    .card-body h2 { font-size: 21px; }
    .checkbox-container, .forgot-password { font-size: 13px; }
}

/* Telas baixas (paisagem ou teclado aberto): topo compacto */
@media (max-height: 600px) {
    .card-header-blue { min-height: 0; padding-top: calc(env(safe-area-inset-top) + 16px); padding-bottom: 40px; }
    .logo-img { width: 72px; }
    .card-body { padding-top: 22px; }
    .subtitle { margin-bottom: 14px; }
    .form-group { margin-bottom: 10px; }
    .card-footer { padding-top: 12px; margin-top: 12px; }
}
@media (min-width: 600px) and (max-height: 600px) {
    .login-wrapper { align-items: flex-start; }
    .card-header-blue { padding-bottom: 18px; }
}

/* =====================================================================
   MODAL DE ALERTA
   ===================================================================== */
.app-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;           /* celular: sobe de baixo (bottom sheet) */
    justify-content: center;
}
.app-modal[hidden] { display: none; }

.app-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 13, 36, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.app-modal__sheet {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 26px 26px 0 0;
    padding: 14px 24px calc(env(safe-area-inset-bottom) + 22px);
    text-align: center;
    box-shadow: 0 -20px 50px rgba(2, 13, 36, 0.25);
    transform: translateY(100%);
    transition: transform 0.35s var(--ease-out);
}

.app-modal.is-open .app-modal__backdrop { opacity: 1; }
.app-modal.is-open .app-modal__sheet { transform: none; }

.app-modal__handle {
    display: block;
    width: 42px;
    height: 5px;
    margin: 0 auto 18px;
    border-radius: 99px;
    background: #e2e8f0;
}

.app-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.app-modal__close:hover { background: #e2e8f0; color: var(--text-main); }

.app-modal__icon {
    width: 68px;
    height: 68px;
    margin: 6px auto 16px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #0070e0;
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    box-shadow: inset 0 0 0 1px rgba(0, 112, 224, 0.12);
}

.app-modal__title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: var(--text-main);
}

.app-modal__text {
    margin: 0 auto 22px;
    max-width: 320px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-muted);
}

.app-modal__btn {
    width: 100%;
    height: 52px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--primary-grad);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 120, 240, 0.28);
    transition: transform 0.12s ease, filter 0.2s;
}
.app-modal__btn:hover { filter: brightness(1.05); }
.app-modal__btn:active { transform: scale(0.98); }
.app-modal__btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(0, 132, 255, 0.3); }

/* Telas maiores: diálogo centralizado */
@media (min-width: 600px) {
    .app-modal { align-items: center; padding: 24px; }
    .app-modal__sheet {
        max-width: 380px;
        border-radius: 24px;
        padding: 30px 28px 26px;
        box-shadow: 0 30px 80px rgba(2, 13, 36, 0.4);
        transform: translateY(12px) scale(0.96);
        opacity: 0;
        transition: transform 0.3s var(--ease-out), opacity 0.2s ease;
    }
    .app-modal.is-open .app-modal__sheet { transform: none; opacity: 1; }
    .app-modal__handle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .login-card { opacity: 1; transform: none; }
}
