/* ==========================================================================
   Traive brand layer — traive-v4
   Look and feel derived from https://traive.com.br/
     navy      #122744   (hero background)
     lime      #C4F978   (accent / primary action)
     ink       #F7F9FC   (heading on navy)
     typeface  Igual (IgualUI-Medium, weight 500) + system fallback
   ========================================================================== */

/* --- Brand typeface -------------------------------------------------------
   Self-hosted so the login page has no external font dependency. */
@font-face {
    font-family: "Igual";
    src: url("../fonts/IgualUI-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Brand palette (from the live site) */
    --traive-navy: #122744;
    --traive-navy-700: #0D1D33;
    --traive-navy-500: #274881;
    --traive-lime: #C4F978;
    --traive-lime-600: #A8E053;
    --traive-green: #05CC56;
    --traive-agro: #46AE50;        /* botao "Para o Agronegocio" no site */
    --traive-agro-600: #3C9845;
    --traive-blue: #3853BD;

    --traive-ink: #F7F9FC;
    --traive-muted: #98A6BC;
    --traive-border: rgba(196, 249, 120, .28);

    --traive-surface: #FFFFFF;
    --traive-text: #122744;
    --traive-text-muted: #475467;
    --traive-field-border: #D0D7E2;

    --traive-radius-pill: 9999px;
    --traive-radius-card: 20px;
    --traive-radius-field: 10px;

    --traive-font: "Igual", -apple-system, "system-ui", "Segoe UI", Roboto,
                   "Helvetica Neue", Arial, sans-serif;

    /* Patternfly global overrides so PF components inherit the brand */
    --pf-global--FontFamily--sans-serif: var(--traive-font);
    --pf-global--FontFamily--redhat--sans-serif: var(--traive-font);
    --pf-global--FontFamily--redhatVF--sans-serif: var(--traive-font);
    --pf-global--FontFamily--heading--sans-serif: var(--traive-font);
    --pf-global--primary-color--100: var(--traive-navy);
    --pf-global--primary-color--200: var(--traive-navy-700);
    --pf-global--link--Color: var(--traive-navy-500);
    --pf-global--BorderColor--300: var(--traive-field-border);
    --pf-global--placeholder-color: #98A2B3;
    --pf-global--FontSize--sm: 14px;
    --pf-global--danger-color--100: #B42318;
    --pf-global--danger-color--200: #B42318;
    --pf-global--success-color--100: #067647;
    --pf-global--success-color--200: #067647;
    --pf-global--warning-color--100: #B54708;
    --pf-global--warning-color--200: #B54708;
}

/* --- Missing-asset neutralisation ----------------------------------------
   The bundled Patternfly stylesheets reference font and image files that are
   not shipped with this theme (../fonts/OpenSans-*, ../fonts/fontawesome-*,
   ../img/bg-login.jpg, @patternfly assets/*). Each produced a 404 on every
   page load. The local @font-face + icon rules below re-point those families
   at fonts that DO exist in this theme, and the background rules drop the
   image requests entirely. */

/* Patternfly's own text/display families -> brand font (no file fetch). */
@font-face {
    font-family: "Open Sans";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 300 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Red Hat Text";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Red Hat Display";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "RedHatText";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "RedHatDisplay";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "overpass";
    src: local("Helvetica Neue"), local("Arial"), local("sans-serif");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* Icon fonts: the PatternFly/FontAwesome/glyphicon webfonts are absent, so the
   glyphs would render as tofu. Use the theme's own pficon.woff2 (present) and
   fall back to inline SVG/text for the handful of icons the login flow uses. */
@font-face {
    font-family: "FontAwesome";
    src: url("./pficon.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: "PatternFlyIcons-webfont";
    src: url("./pficon.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}
@font-face {
    font-family: "Glyphicons Halflings";
    src: url("./pficon.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

/* Kill the image requests Patternfly makes for backgrounds/spinners.
   NOTE: .login-pf-page is deliberately excluded here — it carries the brand
   gradient defined further down, and an !important reset would override it. */
.login-pf,
.login-pf body,
.pf-c-background-image,
.pf-c-background-image::before,
.login-pf-page .container,
.pf-c-login,
.pf-c-login__container {
    background-image: none !important;
}

/* ==========================================================================
   Page shell — navy hero with the site's dot-grid
   The marketing site draws the grid on a <canvas>; reproduced here as two
   radial-gradient layers so no JavaScript or image file is needed.
   ========================================================================== */

html.login-pf {
    height: 100%;
    background: var(--traive-navy);
}

.login-pf body {
    font-family: var(--traive-font);
    background-color: var(--traive-navy);
    color: var(--traive-ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.login-pf-page {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2.5rem 1.25rem 2rem;
    overflow: hidden;
    /* Flat navy, matching the site hero (#122744 with no gradient): the glow
       layers this used to carry lit one corner and made the dot grid read as a
       bright patch instead of an even field. */
    background-color: var(--traive-navy);
}

/* dot-grid layer, masked so it fades toward the centre like the site hero */
.login-pf-page::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, .05) 1.6px, transparent 1.6px);
    background-size: 18px 18px;
    background-position: 0 0;
    -webkit-mask-image: radial-gradient(ellipse 78% 62% at 50% 45%, transparent 22%, #000 82%);
            mask-image: radial-gradient(ellipse 78% 62% at 50% 45%, transparent 22%, #000 82%);
    opacity: .9;
}

/* Interactive canvas grid (js/dots-background.js). When it starts it takes
   over the grid, so the static layer above steps aside to avoid a double
   grid at two different spacings. */
/* Fixed to the viewport rather than absolute inside the page: the canvas
   carries intrinsic dimensions from its width/height attributes (device
   pixels), so an in-flow canvas would push the page taller, the script would
   resize to the taller page, and the two would inflate each other. Fixed
   positioning takes it out of the page's layout entirely. */
.traive-dots-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    display: block;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

.login-pf-page.traive-dots-active::before {
    display: none;
}

/* :not(canvas) so the fixed dot-grid keeps its positioning — the blanket rule
   would drop it back into the flow and stack it above the content. */
.login-pf-page > *:not(.traive-dots-canvas) {
    position: relative;
    z-index: 1;
}

/* --- Brand lockup above the card ---------------------------------------- */
#traive-logo-farm {
    width: 100%;
    max-width: 420px;
    height: 92px;
    margin: 0 auto 1.75rem;
    /* Official brand asset (brand-bgcolor-white.png). Only a 176x31 version is
       published, so it is drawn at its native size to stay sharp rather than
       upscaled. It is a white wordmark, hence navy background only. */
    background-image: url("../img/traive-logo.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 176px 31px;
}

/* Footer mark under the card */
#traive-logo {
    /* Emblem only. Measured from the official PNG: the mark occupies x=1..31
       and the wordmark starts at x=37, so a 30px window offset by -1px shows
       the emblem without clipping the "T". */
    width: 30px;
    height: 31px;
    margin: 2rem auto 0;
    background-image: url("../img/traive-logo.png");
    background-repeat: no-repeat;
    background-position: -1px center;
    background-size: 176px 31px;
    opacity: .75;
}

/* ==========================================================================
   Login card
   ========================================================================== */

.login-pf-page .card-pf {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding: 2.5rem 2.25rem 2rem;
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: var(--traive-radius-card);
    background: var(--traive-surface);
    box-shadow: 0 24px 60px -12px rgba(5, 14, 28, .55),
                0 0 0 1px rgba(255, 255, 255, .04);
}

.login-pf-page .login-pf-header {
    margin-bottom: .5rem;
    text-align: center;
}

.login-pf-page .login-pf-header h1,
h1#kc-page-title {
    margin: 0 0 .35rem;
    font-family: var(--traive-font);
    font-size: 26px;
    font-weight: 500;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--traive-text);
}

#kc-content,
#kc-content-wrapper {
    width: 100%;
}

#kc-content-wrapper {
    margin-top: 1.25rem;
}

#kc-form-wrapper {
    padding: 0;
}

/* ==========================================================================
   Form fields
   ========================================================================== */

.pf-c-form__label,
.pf-c-form__label-text {
    font-family: var(--traive-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--traive-text);
}

.form-group,
.pf-c-form__group {
    margin-bottom: 1.15rem;
}

.pf-c-form-control {
    width: 100%;
    height: 48px;
    padding: 0 .875rem;
    font-family: var(--traive-font);
    font-size: 15px;
    color: var(--traive-text);
    background-color: #FFFFFF;
    border: 1px solid var(--traive-field-border);
    border-radius: var(--traive-radius-field);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.pf-c-form-control:not(textarea),
.pf-c-button.btn-lg {
    height: 48px;
}

textarea.pf-c-form-control {
    height: auto;
    padding: .625rem .875rem;
}

.pf-c-form-control::placeholder {
    color: var(--pf-global--placeholder-color);
    opacity: 1;
}

.pf-c-form-control:hover {
    border-color: #9FB0C9;
}

.pf-c-form-control:focus,
.pf-c-form-control:active {
    border-color: var(--traive-lime-600);
    box-shadow: 0 0 0 4px rgba(196, 249, 120, .35);
    outline: none;
}

.pf-c-form-control[aria-invalid="true"] {
    border-color: var(--pf-global--danger-color--100);
}

.pf-c-form-control[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 4px rgba(180, 35, 24, .18);
}

/* ==========================================================================
   Buttons — the site uses full pills
   ========================================================================== */

.pf-c-button {
    font-family: var(--traive-font);
    border-radius: var(--traive-radius-pill);
    transition: background-color .15s ease, color .15s ease,
                border-color .15s ease, box-shadow .15s ease;
}

/* Primary action mirrors the site's "Para o Agronegocio" button: solid agro
   green, full pill, white label. Hover flips to the outlined variant of the
   same button. */
form .pf-c-button.pf-m-primary,
.pf-c-button.pf-m-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .8rem 2rem;
    font-family: var(--traive-font);
    font-size: 16px;
    font-weight: 500;
    color: #FFFFFF;
    background: var(--traive-agro);
    border: 1px solid var(--traive-agro);
    border-radius: var(--traive-radius-pill);
}

form .pf-c-button.pf-m-primary:hover,
form .pf-c-button.pf-m-primary:focus,
.pf-c-button.pf-m-primary:hover,
.pf-c-button.pf-m-primary:focus {
    color: #FFFFFF;
    background: var(--traive-agro-600);
    border-color: var(--traive-agro-600);
    box-shadow: 0 6px 18px -8px rgba(70, 174, 80, .8);
}

.pf-c-button.pf-m-primary:focus-visible {
    outline: 2px solid var(--traive-agro);
    outline-offset: 3px;
}

/* Outlined variant of the same button, for secondary actions on navy. */
.traive-btn-outline,
.login-pf-page > .pf-c-button.pf-m-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .8rem 2rem;
    font-family: var(--traive-font);
    font-size: 16px;
    font-weight: 500;
    color: #FFFFFF;
    background: transparent;
    border: 1px solid var(--traive-agro);
    border-radius: var(--traive-radius-pill);
}

.traive-btn-outline:hover {
    background: var(--traive-agro);
    color: #FFFFFF;
}

.pf-c-button.pf-m-block {
    width: 100%;
}

#kc-form-buttons {
    margin-top: 1.5rem;
}

/* Secondary / control buttons (social, "try another way") */
.pf-c-button.pf-m-control {
    color: var(--traive-text);
    background: #FFFFFF;
    border: 1px solid var(--traive-field-border);
}

/* PatternFly draws a second, square outline on control buttons through
   ::after (it forces border-radius: initial), which boxed the rounded social
   buttons. The theme's own border is the only frame these need. */
.pf-c-button.pf-m-control::after {
    display: none;
}

.pf-c-button.pf-m-control:hover {
    border-color: var(--traive-navy);
    background: #F7F9FC;
}

/* ==========================================================================
   Links, options, alerts
   ========================================================================== */

.login-pf a,
#kc-info-wrapper a,
.pf-passwordReset a {
    color: var(--traive-navy-500);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.login-pf a:hover,
.pf-passwordReset a:hover {
    color: var(--traive-navy);
    text-decoration: underline;
}

.pf-passwordReset {
    margin-top: .35rem;
    text-align: center;
}

#kc-form-options .checkbox,
.pf-c-check__label,
.pf-c-radio__label {
    font-size: 14px;
    color: var(--traive-text-muted);
}

.pf-c-check__input:focus {
    outline: 2px solid var(--traive-lime-600);
    outline-offset: 1px;
}

/* Alerts */
.pf-c-alert.pf-m-inline {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
    padding: .75rem .875rem;
    border: 1px solid #E4E7EC;
    border-left: 3px solid #E4E7EC;
    border-radius: 10px;
    background: #F9FAFB;
}

.pf-c-alert.pf-m-inline::before {
    content: none;
}

.pf-c-alert__icon {
    padding: 0;
    font-size: 15px;
    line-height: 1.4;
}

.pf-c-alert__title {
    padding: 0;
    font-family: var(--traive-font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.pf-c-alert.pf-m-danger  { border-left-color: var(--pf-global--danger-color--100);  background: #FEF3F2; }
.pf-c-alert.pf-m-success { border-left-color: var(--pf-global--success-color--100); background: #ECFDF3; }
.pf-c-alert.pf-m-warning { border-left-color: var(--pf-global--warning-color--100); background: #FFFAEB; }
.pf-c-alert.pf-m-info    { border-left-color: var(--traive-navy-500);               background: #EFF4FF; }

.pf-c-alert.pf-m-danger  .pf-c-alert__icon, .pf-c-alert.pf-m-danger  .pf-c-alert__title { color: var(--pf-global--danger-color--100); }
.pf-c-alert.pf-m-success .pf-c-alert__icon, .pf-c-alert.pf-m-success .pf-c-alert__title { color: var(--pf-global--success-color--100); }
.pf-c-alert.pf-m-warning .pf-c-alert__icon, .pf-c-alert.pf-m-warning .pf-c-alert__title { color: var(--pf-global--warning-color--100); }

.pf-c-form__helper-text.pf-m-error {
    margin-top: .35rem;
    font-size: 13px;
    color: var(--pf-global--danger-color--100);
}

/* Sign-up / info footer */
.login-pf-page .login-pf-signup,
#kc-info-wrapper {
    padding: 1rem 0 0;
    font-size: 14px;
    color: var(--traive-text-muted);
    text-align: center;
    background: transparent;
}

#kc-info {
    margin: 1rem 0 0;
    border-top: 1px solid #EAECF0;
}

#kc-registration,
#kc-registration-container {
    margin-bottom: 0;
    text-align: center;
}

/* Attempted username / restart */
#kc-username {
    margin-bottom: 0;
    text-align: center;
}

#kc-attempted-username {
    font-family: var(--traive-font);
    font-size: 15px;
    font-weight: 500;
    color: var(--traive-text-muted);
}

/* ==========================================================================
   Locale dropdown
   ========================================================================== */

#kc-locale {
    position: absolute;
    top: 1.5rem;
    right: 1.75rem;
    z-index: 20;
    text-align: right;
}

#kc-locale-dropdown {
    /* Positioning context for the menu below, so it opens directly under the
       link instead of being placed against a distant ancestor. */
    position: relative;
    display: inline-block;
}

#kc-locale-dropdown a,
a#kc-current-locale-link {
    font-family: var(--traive-font);
    font-size: 14px;
    font-weight: 500;
    color: rgba(247, 249, 252, .85);
    text-decoration: none;
}

a#kc-current-locale-link:hover {
    color: var(--traive-lime);
}

/* The trigger is an icon-only button now, so it gets a square hit area and a
   subtle hover surface instead of the text chevron the label used to carry. */
a#kc-current-locale-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    line-height: 0;
    transition: background-color .15s ease, color .15s ease;
}

a#kc-current-locale-link .kc-locale-globe {
    width: 20px;
    height: 20px;
    display: block;
}

#kc-locale ul {
    display: none;
    /* Anchored to #kc-locale-dropdown: right-aligned, just under the link. */
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 30;
    min-width: 168px;
    margin-top: .35rem;
    padding: .35rem;
    border: 1px solid #EAECF0;
    border-radius: 12px;
    background: #FFFFFF;
    box-shadow: 0 12px 28px -8px rgba(5, 14, 28, .35);
    list-style: none;
    text-align: left;
}

#kc-locale-dropdown:hover ul,
#kc-locale-dropdown:focus-within ul {
    display: block;
}

#kc-locale ul li a,
.pf-c-dropdown__menu-item {
    display: block;
    padding: .5rem .75rem;
    border-radius: 8px;
    font-size: 14px;
    color: var(--traive-text) !important;
    text-align: left;
    text-decoration: none;
}

#kc-locale ul li a:hover,
.pf-c-dropdown__menu-item:hover {
    background: #F2F7EA;
    color: var(--traive-navy) !important;
}

/* Active language marker: the globe trigger no longer names it. */
#kc-locale ul li a.kc-locale-item-active {
    position: relative;
    padding-right: 1.75rem;
    font-weight: 600;
    color: var(--traive-navy) !important;
}

#kc-locale ul li a.kc-locale-item-active::after {
    content: "\2713";
    position: absolute;
    top: 50%;
    right: .75rem;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--traive-green, #6C9A2F);
}

/* ==========================================================================
   Social / identity providers
   ========================================================================== */

.kc-social-links {
    margin-top: 1.25rem;
}

.kc-social-section {
    text-align: center;
}

.kc-social-item {
    margin-bottom: .5rem;
    font-size: 15px;
    text-align: center;
}

.kc-social-provider-logo {
    float: left;
    width: 30px;
    height: 25px;
    font-size: 21px;
}

.kc-social-gray {
    color: var(--traive-text-muted);
}

.kc-social-grid {
    display: grid;
    grid-column-gap: 10px;
    grid-row-gap: 6px;
}

/* ==========================================================================
   Select-authenticator / OTP tiles
   ========================================================================== */

.select-auth-box-parent {
    padding: 1rem 0;
    border-top: 1px solid #EAECF0;
    cursor: pointer;
}

.select-auth-box-parent:hover {
    background: #F7F9FC;
}

.select-auth-box-icon {
    display: flex;
    flex: 0 0 2em;
    justify-content: center;
    margin-left: 1.25rem;
    margin-right: 1rem;
    color: var(--traive-navy);
}

.select-auth-box-headline {
    font-family: var(--traive-font);
    font-size: 15px;
    font-weight: 500;
    color: var(--traive-navy);
}

.select-auth-box-desc {
    font-size: 13px;
    color: var(--traive-text-muted);
}

.select-auth-box-arrow {
    display: flex;
    align-items: center;
    margin-right: 1rem;
    color: var(--traive-text-muted);
}

.select-auth-container {
    padding-bottom: 0 !important;
}

/* ==========================================================================
   Recovery codes
   ========================================================================== */

.kc-recovery-codes-list {
    columns: 2;
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid #EAECF0;
    border-radius: 10px;
    list-style: none;
}

.kc-recovery-codes-list li {
    margin-bottom: .5rem;
    font-size: 12px;
}

.kc-recovery-codes-list li span {
    display: inline-block;
    width: 18px;
    margin-right: 2px;
    color: var(--traive-text-muted);
    text-align: right;
}

/* ==========================================================================
   Tooltip (restart-login)
   ========================================================================== */

.kc-login-tooltip {
    position: relative;
    display: inline-block;
}

.kc-login-tooltip .kc-tooltip-text {
    position: absolute;
    top: -3px;
    left: 160%;
    z-index: 30;
    visibility: hidden;
    min-width: 140px;
    padding: .4rem .55rem;
    border-radius: 8px;
    background: var(--traive-navy);
    color: #FFFFFF;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    transition: opacity .25s ease;
}

.kc-login-tooltip:hover .kc-tooltip-text {
    visibility: visible;
    opacity: 1;
}

.kc-login-tooltip .kc-tooltip-text::after {
    content: "";
    position: absolute;
    top: 12px;
    right: 100%;
    border: 5px solid transparent;
    border-right-color: var(--traive-navy);
}

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

@media (max-width: 575px) {
    .login-pf-page {
        padding: 1.75rem 1rem 1.5rem;
    }

    .login-pf-page .card-pf {
        max-width: 100%;
        padding: 1.75rem 1.25rem 1.5rem;
        border-radius: 16px;
    }

    .login-pf-page .login-pf-header h1,
    h1#kc-page-title {
        font-size: 22px;
    }

    #traive-logo-farm {
        height: 68px;
        margin-bottom: 1.25rem;
        background-size: 176px 31px;
    }

    #kc-locale {
        top: 1rem;
        right: 1rem;
    }

    .kc-social-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 700px) {
    .login-pf-page {
        justify-content: flex-start;
    }

    #traive-logo-farm {
        height: 64px;
        margin-bottom: 1rem;
        background-size: 176px 31px;
    }

    #traive-logo {
        margin-top: 1.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================================================
   Organization selector — two-step: pick a type, then pick an organization
   The steps are toggled with :target (see select-organization.ftl), so the
   browser Back button works and no JavaScript is involved.
   ========================================================================== */

.kc-org-select-title {
    margin: 0 0 1.25rem;
    font-family: var(--traive-font);
    font-size: 17px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--traive-text);
    text-align: center;
}

/* --- Step machinery ------------------------------------------------------ */

/* Single type: only one panel exists, so always show it. */
.kc-org-step {
    display: block;
}

/* Stepped mode: show the type chooser, hide every organization list until its
   own id is targeted. */
.kc-org-stepped .kc-org-step-orgs {
    display: none;
}

.kc-org-stepped .kc-org-step-orgs:target {
    display: block;
}

/* Once any organization list is targeted, retire the type chooser. Uses :has
   so it reacts to the fragment without scripting; browsers without :has simply
   keep the chooser visible above the list, which still works. */
.kc-org-stepped:has(.kc-org-step-orgs:target) .kc-org-step-types {
    display: none;
}

/* --- Step 1: type cards -------------------------------------------------- */

.kc-org-type-list,
.kc-org-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kc-org-type-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--traive-field-border);
    border-left-width: 4px;
    border-radius: 14px;
    background: #FFFFFF;
    font-family: var(--traive-font);
    text-decoration: none;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease,
                box-shadow .15s ease, transform .15s ease;
}

.kc-org-type-item:hover {
    background: #FAFDF4;
    box-shadow: 0 6px 18px -8px rgba(18, 39, 68, .25);
    text-decoration: none;
}

.kc-org-type-item:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(196, 249, 120, .35);
}

.kc-org-type-item:active {
    transform: translateY(1px);
}

.kc-org-type-body {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}

.kc-org-type-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--traive-text);
}

.kc-org-type-meta {
    font-size: 13px;
    color: var(--traive-text-muted);
}

/* Type accent, matching the organization stripes below. */
.kc-org-type-item[data-org-type="SELLER"] { border-left-color: var(--traive-green); }
.kc-org-type-item[data-org-type="BUYER"]  { border-left-color: var(--traive-blue); }
.kc-org-type-item[data-org-type="SELLER"]:hover { border-color: var(--traive-green); border-left-color: var(--traive-green); }
.kc-org-type-item[data-org-type="BUYER"]:hover  { border-color: var(--traive-blue);  border-left-color: var(--traive-blue); }

/* --- Step 2: back link --------------------------------------------------- */

.kc-org-back {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: .85rem;
    font-family: var(--traive-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--traive-navy-500);
    text-decoration: none;
}

.kc-org-back:hover {
    color: var(--traive-navy);
    text-decoration: underline;
}

.kc-org-back:focus-visible {
    outline: 2px solid var(--traive-lime-600);
    outline-offset: 3px;
    border-radius: 6px;
}

.kc-org-back-arrow {
    font-size: 18px;
    line-height: 1;
}

/* --- Step 2: organization buttons ---------------------------------------- */

.kc-org-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    width: 100%;
    padding: .85rem 1rem;
    border: 1px solid var(--traive-field-border);
    border-radius: 12px;
    background: #FFFFFF;
    font-family: var(--traive-font);
    font-size: 15px;
    font-weight: 500;
    color: var(--traive-text);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease,
                box-shadow .15s ease, transform .15s ease;
}

.kc-org-item:hover {
    border-color: var(--traive-lime-600);
    background: #FAFDF4;
    box-shadow: 0 4px 14px -6px rgba(18, 39, 68, .22);
}

.kc-org-item:focus-visible {
    outline: none;
    border-color: var(--traive-lime-600);
    box-shadow: 0 0 0 4px rgba(196, 249, 120, .35);
}

.kc-org-item:active {
    transform: translateY(1px);
}

.kc-org-item-name {
    flex: 1 1 auto;
    min-width: 0;
    /* Full-width rows have room, so wrap long names instead of truncating. */
    overflow-wrap: anywhere;
}

.kc-org-item-arrow {
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1;
    color: var(--traive-text-muted);
}

.kc-org-item:hover .kc-org-item-arrow,
.kc-org-type-item:hover .kc-org-item-arrow {
    color: var(--traive-navy);
}

/* Accent stripe per organization type. Only SELLER (agro side) and BUYER
   (financial side) are listed; other types are filtered out in the template. */
.kc-org-step-orgs[data-org-type="SELLER"] .kc-org-item { border-left: 3px solid var(--traive-green); }
.kc-org-step-orgs[data-org-type="BUYER"]  .kc-org-item { border-left: 3px solid var(--traive-blue); }

/* Nothing selectable: explain rather than showing an empty card. */
.kc-org-empty {
    padding: .5rem 0 .25rem;
    text-align: center;
}

.kc-org-empty-text {
    margin: 0 0 1rem;
    font-family: var(--traive-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--traive-text-muted);
}

.kc-org-empty .kc-org-back {
    margin-bottom: 0;
}

/* --- Step 2: search box --------------------------------------------------
   Only rendered for lists past the scroll threshold, and kept hidden until
   org-search.js reveals it (the filtering itself is client-side). */

.kc-org-search {
    position: relative;
    margin: 0 0 .75rem;
}

.kc-org-search-input {
    width: 100%;
    padding: .6rem 2.25rem .6rem .9rem;
    border: 1px solid var(--traive-field-border);
    border-radius: 12px;
    background: #FFFFFF;
    font-family: var(--traive-font);
    font-size: 14px;
    color: var(--traive-text);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.kc-org-search-input::placeholder {
    color: var(--traive-text-muted);
}

.kc-org-search-input:focus {
    outline: none;
    border-color: var(--traive-lime-600);
    box-shadow: 0 0 0 4px rgba(196, 249, 120, .35);
}

/* The icon sits over the input, so clicks must pass through to the field. */
.kc-org-search-icon {
    position: absolute;
    top: 50%;
    right: .85rem;
    transform: translateY(-50%);
    display: flex;
    color: var(--traive-text-muted);
    pointer-events: none;
}

.kc-org-search-empty {
    margin: .85rem 0 0;
    font-family: var(--traive-font);
    font-size: 14px;
    color: var(--traive-text-muted);
    text-align: center;
}

/* More than 5 organizations: scroll the list instead of letting the card grow
   past the viewport. The template adds .kc-org-list-scroll (CSS cannot count
   children).
     row  = .85rem*2 padding + 1.125rem line + .125rem borders = 2.95rem
     gap  = .5rem
   Height shows 5 whole rows plus a sliver of the 6th, so it is visually obvious
   the list continues. Horizontal padding leaves room for the focus ring; the
   negative margin keeps rows flush with the rest of the card. */
.kc-org-list-scroll {
    --kc-org-row: 2.95rem;
    --kc-org-gap: .5rem;
    max-height: calc(var(--kc-org-row) * 5 + var(--kc-org-gap) * 5 + .75rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 6px;
    margin: -4px -6px;
    scrollbar-width: thin;
    scrollbar-color: var(--traive-field-border) transparent;
}

.kc-org-list-scroll::-webkit-scrollbar {
    width: 8px;
}

.kc-org-list-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.kc-org-list-scroll::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 4px;
    background-clip: content-box;
    background-color: #C7D0DE;
}

.kc-org-list-scroll::-webkit-scrollbar-thumb:hover {
    background-color: var(--traive-muted);
}

/* Single-column list, so the selector card keeps the login card's width. */
.login-pf-page .card-pf:has(#kc-user-organizations) {
    max-width: 460px;
}

/* Organizations are always a single vertical list — one full-width row each,
   never side by side. .kc-org-list is already a column flex container, so no
   responsive override is needed here. */
/* The brand lockup is an anchor; keep it from picking up link styling. */
a#traive-logo-farm {
    display: block;
    text-decoration: none;
}

a#traive-logo-farm:hover {
    opacity: .9;
}

a#traive-logo-farm:focus-visible {
    outline: 2px solid var(--traive-lime);
    outline-offset: 6px;
    border-radius: 8px;
}

/* ==========================================================================
   Corrections found during visual review
   ========================================================================== */

/* 1. The locale dropdown is positioned inside the white card on pages whose
      header renders it there (organization selector, attempted-username
      screens). Light-on-white was unreadable, so scope the light treatment to
      the page background and use ink on the card. */
#kc-locale {
    /* Inside the card the selector flows with the header instead of being
       pinned to the page corner. The menu is anchored to #kc-locale-dropdown,
       so this staying static does not affect it. */
    position: static;
    margin: 0 0 .25rem;
    text-align: right;
}

/* The menu sits .35rem below the link. Bridge that gap with a transparent
   pseudo-element so moving the pointer down does not leave the hover area and
   close the menu. */
#kc-locale ul::before {
    content: "";
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: .45rem;
}

#kc-locale-dropdown:hover ul,
#kc-locale-dropdown:focus-within ul {
    display: block;
}

#kc-locale-dropdown a,
a#kc-current-locale-link {
    color: var(--traive-text-muted);
}

a#kc-current-locale-link:hover,
#kc-locale-dropdown:focus-within a#kc-current-locale-link {
    color: var(--traive-navy);
    background: #F2F7EA;
}

/* Keep the light variant when the dropdown sits directly on the navy page. */
.login-pf-page > #kc-locale a#kc-current-locale-link {
    color: rgba(247, 249, 252, .85);
    background: transparent;
}

.login-pf-page > #kc-locale a#kc-current-locale-link:hover,
.login-pf-page > #kc-locale #kc-locale-dropdown:focus-within a#kc-current-locale-link {
    color: var(--traive-lime);
    background: rgba(247, 249, 252, .12);
}

/* 2. The restart-login affordance uses a Patternfly icon font that this theme
      does not ship, so it rendered as a tofu box. Hide the glyph and draw the
      arrow with a character that exists in the brand font. */
#reset-login .kc-login-tooltip i.pficon,
#reset-login .kc-login-tooltip i.fa {
    font-family: inherit;
    font-style: normal;
}

#reset-login .kc-login-tooltip i.pficon::before,
#reset-login .kc-login-tooltip i.fa::before {
    content: "\21BB";           /* ↻ clockwise open circle arrow */
    font-family: inherit;
    font-size: 15px;
    line-height: 1;
    color: var(--traive-navy-500);
}

#reset-login:hover .kc-login-tooltip i::before {
    color: var(--traive-navy);
}

#kc-username {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    margin-bottom: .75rem;
}

/* 3. The footer mark was too small and too faint to read as a logo. */
#traive-logo {
    width: 30px;
    height: 30px;
    margin-top: 1.5rem;
    opacity: .4;
}

/* Alert icons come from the same missing icon font; fall back to text marks so
   error/warning/success states stay legible. */
.pf-c-alert__icon .fa,
.pf-c-alert__icon .pficon {
    font-family: inherit;
    font-style: normal;
}

.pf-c-alert.pf-m-danger  .pf-c-alert__icon .fa::before,
.pf-c-alert.pf-m-danger  .pf-c-alert__icon .pficon::before { content: "\26A0"; }
.pf-c-alert.pf-m-warning .pf-c-alert__icon .fa::before,
.pf-c-alert.pf-m-warning .pf-c-alert__icon .pficon::before { content: "\26A0"; }
.pf-c-alert.pf-m-success .pf-c-alert__icon .fa::before,
.pf-c-alert.pf-m-success .pf-c-alert__icon .pficon::before { content: "\2713"; }
.pf-c-alert.pf-m-info    .pf-c-alert__icon .fa::before,
.pf-c-alert.pf-m-info    .pf-c-alert__icon .pficon::before { content: "\2139"; }

.pf-c-alert__icon .fa::before,
.pf-c-alert__icon .pficon::before {
    font-family: inherit;
    font-size: 15px;
    line-height: 1.3;
}
