/* Layout de autenticação alinhado à tela inicial (/) — independente do grid legacy */

.login-page-layout--home {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: relative;
    min-height: 100dvh;
    max-height: 100dvh;
    height: 100dvh;
    padding: 0;
    overflow: hidden;
    background-color: var(--caprind-shell-bg) !important;
    background-image: none !important;
    box-sizing: border-box;
}

.login-page-layout--home.login-industrial-bg--video {
    background-color: #081628 !important;
    background-image: none !important;
}

.login-page-layout--home > .login-auth-home {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.login-page-layout--home > .login-page-footer {
    flex: 0 0 auto;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.login-page-layout--home .login-copyright-notice {
    width: 100%;
    max-width: 52rem;
    margin-inline: auto;
    padding: 0.35rem clamp(0.75rem, 3vw, 1.5rem);
    text-align: center;
    color: var(--caprind-login-page-footer-text);
    text-shadow: var(--caprind-login-page-footer-text-shadow, none);
}

.login-page-layout--home .login-copyright-notice__line {
    text-align: center;
    margin-inline: auto;
    color: inherit;
}

.login-page-layout--home .login-page-footer:has(.login-page-footer__actions) .login-copyright-notice {
    padding-right: clamp(4.75rem, 13vw, 6.5rem);
}

.login-page-layout--home .login-page-footer {
    position: relative;
}

.login-page-layout--home .login-page-footer__version {
    color: var(--caprind-login-page-footer-text);
    text-shadow: var(--caprind-login-page-footer-text-shadow, none);
    position: static;
    width: 100%;
    max-width: 52rem;
    margin-top: 0.35rem;
    text-align: center;
}

.login-page-layout--home .login-page-footer__actions {
    position: absolute;
    right: clamp(0.75rem, 3vw, 1.5rem);
    bottom: clamp(0.45rem, 1.2vh, 0.75rem);
    z-index: 3;
}

.login-auth-theme-toggle {
    display: flex;
    justify-content: flex-end;
}

.login-auth-theme-toggle .login-theme-toggle-btn {
    border: 1px solid var(--caprind-login-theme-btn-border);
    color: var(--caprind-login-theme-btn-text);
    background: var(--caprind-login-theme-btn-bg);
    font-weight: 600;
    box-shadow: 0 2px 10px color-mix(in srgb, var(--caprind-shell-bg) 28%, transparent);
}

.login-auth-theme-toggle .login-theme-toggle-btn:hover,
.login-auth-theme-toggle .login-theme-toggle-btn:focus-visible {
    border-color: var(--caprind-login-theme-btn-border-hover);
    color: var(--caprind-login-card-text);
    background: var(--caprind-login-theme-btn-bg-hover);
}

.login-auth-home {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    width: 100%;
    max-width: min(94vw, 56rem);
    min-height: 100%;
    margin: 0 auto;
    padding: 0.35rem clamp(0.75rem, 3vw, 1.25rem) 0.15rem;
    gap: 15px;
    box-sizing: border-box;
}

.login-auth-home--landing {
    gap: clamp(0.35rem, 0.9vh, 0.75rem);
}

.login-auth-home__logo {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.login-auth-home__logo .caprind-home-logo-block {
    width: 100%;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.login-auth-home__logo .caprind-home-logo,
.login-auth-home__logo img.caprind-home-logo {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    max-height: clamp(19.2rem, 45.6dvh, 36rem);
    height: auto !important;
    aspect-ratio: auto !important;
    margin: 0;
    object-fit: contain;
    object-position: center bottom;
}

.login-auth-home__body {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    margin: 0;
}

.login-auth-home__body > form {
    width: 100%;
    margin: 0;
}

/* Logo colado no topo do card (login e demais telas de autenticação) */
.login-auth-home:not(.login-auth-home--landing) .app-auth-card.login-card-shell {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}

.page:not([data-caprind-theme-family="light"]) .login-auth-home .caprind-home-logo--theme-light {
    display: none !important;
}

.page[data-caprind-theme-family="light"] .login-auth-home .caprind-home-logo--theme-dark {
    display: none !important;
}

/*
 * Login / assinatura (ShowThemeToggle=false): sempre visual escuro —
 * ignora preferência light salva (logo claro + tipografia do cartão escuro).
 */
.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-auth-home .caprind-home-logo--theme-dark {
    display: block !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-auth-home .caprind-home-logo--theme-light {
    display: none !important;
}

.login-page-forced-dark,
.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark,
.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio.login-card-shell,
.login-page-forced-dark .login-card-materio.login-card-shell {
    /* Tipografia / superfície: sobrescreve tokens do tema claro herdados de .page */
    /* Mesmo cartão translúcido do tema escuro (tokens-semantic). */
    --ds-color-surface-card: linear-gradient(180deg, rgba(11, 29, 49, 0.72) 0%, rgba(12, 34, 56, 0.58) 100%);
    --ds-color-surface: transparent;
    --ds-color-border: color-mix(in srgb, #ffffff 14%, transparent);
    --ds-color-text: #f1f5f9;
    --ds-color-text-muted: color-mix(in srgb, #f1f5f9 72%, transparent);
    --ds-input-bg: color-mix(in srgb, #0b1a2e 72%, transparent);
    --ds-input-text: #f1f5f9;
    --ds-input-border: color-mix(in srgb, #7dd3fc 42%, transparent);
    --ds-input-border-focus: #38bdf8;
    --ds-input-placeholder: color-mix(in srgb, #f1f5f9 45%, transparent);
    --ds-color-link-hover: #7dd3fc;
    --caprind-login-card-bg: linear-gradient(180deg, color-mix(in srgb, var(--ds-color-brand-900) 55%, transparent) 0%, color-mix(in srgb, var(--ds-color-brand-800) 50%, transparent) 100%);
    --caprind-login-card-text: #f1f5f9;
    --caprind-login-card-muted: color-mix(in srgb, #f1f5f9 72%, transparent);
    --caprind-login-card-link: #7dd3fc;
    --caprind-login-card-link-hover: #bae6fd;
    --caprind-login-card-border: color-mix(in srgb, #ffffff 14%, transparent);
    --caprind-login-card-shadow: 0 16px 40px rgba(4, 8, 14, 0.45);
    --caprind-login-brand-divider: color-mix(in srgb, #ffffff 8%, transparent);
    --caprind-login-footer-border: color-mix(in srgb, #ffffff 8%, transparent);
    --caprind-login-db-badge-bg: color-mix(in srgb, #ffffff 8%, transparent);
    --caprind-login-db-badge-text: color-mix(in srgb, #f1f5f9 78%, transparent);
    --caprind-login-db-badge-hover: #f8fafc;
    --caprind-login-eye-color: color-mix(in srgb, #f1f5f9 88%, transparent);
    --caprind-login-label-color: #f1f5f9;
    --caprind-login-lead-color: color-mix(in srgb, #f1f5f9 72%, transparent);
    --caprind-login-remember-label: #e2e8f0;
    --caprind-login-theme-btn-border: color-mix(in srgb, #38bdf8 45%, transparent);
    --caprind-login-theme-btn-text: #f1f5f9;
    --caprind-login-theme-btn-bg: color-mix(in srgb, #ffffff 6%, transparent);
    --caprind-login-theme-btn-border-hover: color-mix(in srgb, #38bdf8 70%, transparent);
    --caprind-login-theme-btn-bg-hover: color-mix(in srgb, #ffffff 12%, transparent);
    --caprind-login-placeholder: color-mix(in srgb, #f1f5f9 45%, transparent);
    --caprind-login-autofill-inset: color-mix(in srgb, var(--ds-color-brand-900) 82%, transparent);
    --caprind-login-page-footer-text: color-mix(in srgb, #f1f5f9 92%, transparent);
    --caprind-login-page-footer-text-shadow: 0 1px 8px color-mix(in srgb, #000000 55%, transparent), 0 0 1px color-mix(in srgb, #000000 85%, transparent);
    --caprind-label-notch-login: color-mix(in srgb, var(--ds-color-brand-900) 82%, transparent);
    --login-label-notch-bg: color-mix(in srgb, var(--ds-color-brand-900) 82%, transparent);
    --login-field-bg: color-mix(in srgb, #0b1a2e 72%, transparent);
    --login-field-text: #f1f5f9;
    --login-field-border: color-mix(in srgb, #7dd3fc 42%, transparent);
    --caprind-field-bg: color-mix(in srgb, #0b1a2e 72%, transparent);
    --caprind-field-text: #f1f5f9;
    --caprind-field-border: color-mix(in srgb, #7dd3fc 42%, transparent);
    --caprind-field-border-hover: color-mix(in srgb, #7dd3fc 65%, transparent);
    --caprind-field-border-focus: #38bdf8;
    --caprind-field-focus-ring: rgba(56, 189, 248, 0.28);
}

/* Fundo do cartão translúcido (como no tema escuro original) */
.login-page-forced-dark .app-auth-card.login-card-shell,
.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .app-auth-card.login-card-shell {
    background: linear-gradient(180deg, rgba(11, 29, 49, 0.72) 0%, rgba(12, 34, 56, 0.58) 100%) !important;
    color: #f1f5f9 !important;
    border-color: color-mix(in srgb, #ffffff 14%, transparent) !important;
    box-shadow: 0 16px 40px rgba(4, 8, 14, 0.32) !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-card-title {
    color: #f1f5f9 !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-card-lead,
.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-card-muted {
    color: color-mix(in srgb, #f1f5f9 72%, transparent) !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-remember-label {
    color: #e2e8f0 !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-accent-link {
    color: #7dd3fc !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-eye-toggle {
    color: color-mix(in srgb, #f1f5f9 88%, transparent) !important;
}

.page[data-caprind-theme-family="light"] .login-industrial-bg.login-page-forced-dark .login-card-materio .login-eye-toggle:hover {
    color: #7dd3fc !important;
}

@media (max-width: 767.98px) {
    /*
     * Celular: viewport fixa + scroll interno se o teclado abrir.
     * Evita a composição “faixa de vídeo + logo gigante + form cortado”.
     */
    .login-page-layout--home:not(:has(.login-auth-home--landing)) {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /*
     * Fundo sempre na viewport (nunca no fluxo do documento).
     * Com height do host ≠ 100% do scroll, absolute inset:0 estica/corta o cover.
     */
    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__fallback,
    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__video,
    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__scrim {
        position: fixed !important;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        max-width: 100%;
        max-height: 100dvh;
        object-fit: cover;
        object-position: center 32%;
        pointer-events: none;
    }

    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__fallback {
        z-index: 1;
    }

    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__video {
        z-index: 0;
    }

    .login-page-layout--home.login-industrial-bg--video.caprind-bg-video-host--ready > .login-industrial-bg__video,
    .login-page-layout--home.login-industrial-bg--video:has(.login-industrial-bg__video.caprind-bg-video--ready) > .login-industrial-bg__video {
        z-index: 1;
    }

    .login-page-layout--home.login-industrial-bg--video > .login-industrial-bg__scrim {
        z-index: 2;
    }

    .login-page-layout--home > .login-auth-home {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        overflow: visible;
        min-height: 100%;
        position: relative;
        z-index: 3;
    }

    .login-page-layout--home > .login-page-footer {
        flex: 0 0 auto;
        position: relative;
        z-index: 3;
    }

    .login-auth-home:not(.login-auth-home--landing) {
        justify-content: flex-end;
        gap: 0.45rem;
        min-height: 100%;
        max-width: min(96vw, 26rem);
        padding: 0.5rem 0.75rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
    }

    .login-auth-home:not(.login-auth-home--landing) .login-auth-home__logo {
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        width: 100%;
        max-width: min(70vw, 14.5rem);
        margin-inline: auto;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-auth-home__logo .caprind-home-logo-block {
        width: 100%;
        max-width: 100%;
    }

    /* Logo compacto: cabe na 1ª tela com o cartão de login (!important vence CSS isolado). */
    .login-auth-home:not(.login-auth-home--landing) .login-auth-home__logo .caprind-home-logo,
    .login-auth-home:not(.login-auth-home--landing) .login-auth-home__logo img.caprind-home-logo {
        width: 100% !important;
        max-width: 100% !important;
        max-height: min(22dvh, 8.75rem) !important;
        height: auto !important;
        object-fit: contain !important;
        object-position: center bottom !important;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-auth-home__body {
        flex: 0 0 auto;
        width: 100%;
    }

    .login-auth-home:not(.login-auth-home--landing) .app-auth-card.login-card-shell {
        padding: 0.85rem 0.9rem 0.7rem;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-card-header {
        margin-bottom: 0.65rem !important;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-card-title {
        font-size: 1.05rem;
        margin-bottom: 0.25rem !important;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-card-lead {
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .login-auth-home:not(.login-auth-home--landing) .login-field-wrap {
        margin-bottom: 0.65rem !important;
    }
}

.page[data-caprind-theme-family="light"] .login-page-layout--home {
    background-color: var(--caprind-shell-bg) !important;
}

.page[data-caprind-theme="light-blue"] .login-page-layout--home,
.page[data-caprind-theme="light-red"] .login-page-layout--home,
.page[data-caprind-theme="light-green"] .login-page-layout--home {
    background-color: var(--caprind-shell-bg) !important;
}

.page[data-caprind-theme-family="light"] .login-page-layout--home.login-industrial-bg--video,
.page[data-caprind-theme="light-blue"] .login-page-layout--home.login-industrial-bg--video,
.page[data-caprind-theme="light-red"] .login-page-layout--home.login-industrial-bg--video,
.page[data-caprind-theme="light-green"] .login-page-layout--home.login-industrial-bg--video {
    background-color: #081628 !important;
}

/* Landing /assinatura */
.login-auth-home--landing {
    max-width: min(96vw, 72rem);
    justify-content: flex-start;
    gap: clamp(0.35rem, 0.9vh, 0.75rem);
    padding-top: clamp(0.25rem, 0.8vh, 0.65rem);
    padding-bottom: clamp(0.75rem, 2vh, 1.25rem);
}

.login-auth-home--landing .login-auth-home__logo {
    width: min(100%, clamp(22.8rem, 42vw, 33.6rem));
    max-width: clamp(22.8rem, 42vw, 33.6rem);
    margin-inline: auto;
}

.login-auth-home--landing .login-auth-home__logo .caprind-home-logo,
.login-auth-home--landing .login-auth-home__logo img.caprind-home-logo {
    width: min(100%, clamp(22.8rem, 42vw, 33.6rem)) !important;
    max-width: clamp(22.8rem, 42vw, 33.6rem) !important;
    max-height: none;
    height: auto;
}

.login-auth-home--landing .login-auth-home__body.assinatura-landing-shell {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    height: auto;
    min-height: auto;
    max-height: none;
    max-width: 100%;
    overflow: visible;
    margin: 0;
    padding: 0;
}

/* A landing é mais alta que o celular. O documento (html/body) não rola
   (overflow: hidden). Este bloco é o scrollport: altura da viewport e o
   conteúdo cresce por dentro. */
.login-page-layout--home:has(.login-auth-home--landing) {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
}

.login-page-layout--home:has(.login-auth-home--landing) > .login-auth-home--landing {
    flex: 0 0 auto;
    height: auto;
    min-height: min-content;
    max-height: none;
    overflow: visible;
}

.assinatura-landing__btn-primary {
    background: linear-gradient(180deg, var(--caprind-accent) 0%, var(--caprind-accent-hover) 100%);
    border-color: color-mix(in srgb, var(--caprind-accent) 35%, transparent);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--caprind-accent) 32%, transparent);
}

.assinatura-landing__feature-icon {
    color: var(--caprind-accent);
}

.assinatura-landing__btn-secondary {
    color: var(--caprind-login-card-link, var(--caprind-accent));
    border-bottom-color: color-mix(in srgb, var(--caprind-accent) 45%, transparent);
}

.assinatura-landing__btn-secondary:hover,
.assinatura-landing__btn-secondary:focus {
    color: var(--caprind-login-card-link-hover, var(--caprind-accent-hover));
}

.page[data-caprind-theme-family="light"] .assinatura-landing {
    color: #334155;
}

.page[data-caprind-theme-family="light"] .assinatura-landing__hero-title,
.page[data-caprind-theme-family="light"] .assinatura-landing__feature-title,
.page[data-caprind-theme-family="light"] .assinatura-landing__tagline {
    color: #0f172a;
    text-shadow: none;
}

.page[data-caprind-theme-family="light"] .assinatura-landing__hero-lead,
.page[data-caprind-theme-family="light"] .assinatura-landing__feature-text,
.page[data-caprind-theme-family="light"] .assinatura-landing__highlight-text {
    color: #475569;
    text-shadow: none;
}

.page[data-caprind-theme-family="light"] .assinatura-landing__feature,
.page[data-caprind-theme-family="light"] .assinatura-landing__highlight {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(15, 23, 42, 0.1);
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
