/* Подключаем продуктовые шрифты из локальных ресурсов темы Keycloak. */
@font-face {
    font-family: "SB Sans Display";
    src: url("../fonts/SBSansDisplay-Semibold.woff2") format("woff2"),
        url("../fonts/SBSansDisplay-Semibold.woff") format("woff");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "SB Sans Text";
    src: url("../fonts/SBSansText-Regular.woff2") format("woff2"),
        url("../fonts/SBSansText-Regular.woff") format("woff");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "SB Sans Text";
    src: url("../fonts/SBSansText-Medium.woff2") format("woff2"),
        url("../fonts/SBSansText-Medium.woff") format("woff");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* Токены для экрана авторизации в стиле продукта. */
:root {
    --auth-bg: #f2f3f5;
    --auth-card-bg: #ffffff;
    --auth-card-border: #e5e7eb;
    --auth-title: #191b1f;
    --auth-subtitle: #33363c;
    --auth-input-border: #d8dce3;
    --auth-input-placeholder: #8b919c;
    --auth-submit-bg: #15171b;
    --auth-submit-bg-hover: #090b0e;
    --auth-link: #0b6bdb;
    --auth-ui-font-size: 14px;
    --auth-ui-line-height: 20px;
    --auth-ui-letter-spacing: -0.3px;
}

/* Убираем дефолтный декоративный фон Keycloak и задаем ровный фон как в макете. */
body {
    background: var(--auth-bg) !important;
    min-height: 100vh;
    font-family: "SB Sans Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* Делаем логотип в левом верхнем углу ближе к референсу. */
#kc-header {
    position: fixed;
    top: 24px;
    left: 28px;
    margin: 0;
    width: auto;
    z-index: 10;
}

#kc-header-wrapper {
    color: transparent;
    font-size: 0;
    line-height: 0;
    width: 174px;
    height: 40px;
    background: url("../img/logo.png") no-repeat left top / contain;
}

/* Центрируем карточку и убираем визуальный шум от дефолтной темы. */
.login-pf-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 16px 24px;
    box-sizing: border-box;
}

#kc-content {
    width: 100%;
    max-width: 100%;
}

.card-pf {
    width: min(100%, 560px);
    margin: 0 auto;
    background: var(--auth-card-bg);
    border: 1px solid var(--auth-card-border);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(12, 18, 28, 0.06);
    padding: 20px 20px 16px;
}

.login-pf-header {
    margin-bottom: 8px;
}

#kc-page-title {
    margin: 0;
    color: var(--auth-title);
    font-family: "SB Sans Display", "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    line-height: 24px;
    font-weight: 600;
    letter-spacing: -0.18px;
    text-align: left;
}

.gigab2b-login-subtitle {
    margin: 0 0 14px;
    color: var(--auth-subtitle);
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    letter-spacing: -0.3px;
}

/* Поля и кнопка как в референсе: компактные и с мягкими скруглениями. */
#kc-form-wrapper,
#kc-passwd-update-form,
#kc-update-profile-form {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}

:is(#username, #password, #password-new, #password-confirm, .pf-v5-c-form-control) {
    height: 48px;
    min-height: 48px;
    border-radius: 10px;
    border: 1px solid var(--auth-input-border);
    box-shadow: none;
    font-size: var(--auth-ui-font-size);
    font-weight: 500;
    line-height: var(--auth-ui-line-height);
    letter-spacing: var(--auth-ui-letter-spacing);
    padding-inline: 14px;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
}

::placeholder {
    color: var(--auth-input-placeholder);
    opacity: 1;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: var(--auth-ui-font-size);
    line-height: var(--auth-ui-line-height);
    letter-spacing: var(--auth-ui-letter-spacing);
}

#kc-form-login .pf-v5-c-form__label-text,
#kc-passwd-update-form .pf-v5-c-form__label-text,
#kc-update-profile-form .pf-v5-c-form__label-text,
#kc-form-login label,
#kc-passwd-update-form label,
#kc-update-profile-form label {
    color: #2d3138;
    font-size: 13px;
    font-weight: 500;
}

/* Ошибки авторизации: красный текст, красная рамка, без иконок. */
#kc-form-login input[aria-invalid="true"],
#kc-form-login .pf-v5-c-input-group input[aria-invalid="true"] {
    border-color: #DC2626 !important;
    box-shadow: none !important;
    background-image: none !important;
}

#kc-form-login #input-error,
#kc-form-login .pf-v5-c-form__helper-text,
#kc-form-login .pf-v5-c-helper-text__item-text {
    color: #DC2626 !important;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: var(--auth-ui-font-size);
    font-weight: 400;
    line-height: var(--auth-ui-line-height);
    letter-spacing: var(--auth-ui-letter-spacing);
}

/* Ошибки в update profile оформляем в том же стиле, что и в логине. */
#kc-update-profile-form input[aria-invalid="true"] {
    border-color: #DC2626 !important;
    box-shadow: none !important;
    background-image: none !important;
}

#kc-update-profile-form [id^="input-error-"],
#kc-update-profile-form .pf-v5-c-form__helper-text,
#kc-update-profile-form .pf-v5-c-helper-text__item-text {
    color: #DC2626 !important;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: var(--auth-ui-font-size);
    font-weight: 400;
    line-height: var(--auth-ui-line-height);
    letter-spacing: var(--auth-ui-letter-spacing);
}

#kc-form-login #input-error {
    display: block;
    margin-top: 8px;
}

#kc-form-login .pf-v5-c-form__helper-text svg,
#kc-form-login .pf-v5-c-helper-text__item-icon,
#kc-form-login .pf-v5-c-form__helper-text-item-icon,
#kc-form-login .kc-feedback-text::before {
    display: none !important;
    content: none !important;
}

/* На странице обычного логина в макете нет верхних label, оставляем только placeholders. */
body[data-page-id="login-login"] #kc-form-login label {
    display: none;
}

/* Держим кнопку-глаз внутри поля пароля. */
.gigab2b-password-input-group {
    position: relative;
    display: block;
}

.gigab2b-password-input-group input {
    width: 100%;
    padding-right: 44px;
}

.gigab2b-password-input-group button[data-password-toggle] {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-left: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    outline: none !important;
    min-height: 16px;
    min-width: 16px;
    z-index: 2;
}

/* Полностью гасим PatternFly control-обводку/рамки только у кнопки глаза. */
.gigab2b-password-toggle {
    --pf-c-button--after--BorderWidth: 0 !important;
    --pf-c-button--after--BorderColor: transparent !important;
    --pf-c-button--m-control--after--BorderTopColor: transparent !important;
    --pf-c-button--m-control--after--BorderRightColor: transparent !important;
    --pf-c-button--m-control--after--BorderBottomColor: transparent !important;
    --pf-c-button--m-control--after--BorderLeftColor: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.gigab2b-password-toggle::after {
    content: none !important;
    border: 0 !important;
    box-shadow: none !important;
}

.gigab2b-password-toggle:hover,
.gigab2b-password-toggle:focus,
.gigab2b-password-toggle:active {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* Кастомные иконки глаза из темы (2 состояния). */
.gigab2b-eye-show,
.gigab2b-eye-hide {
    display: inline-block;
    width: 16px;
    height: 13px;
    font-size: 0;
    line-height: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 13px;
}

.gigab2b-eye-show {
    background-image: url("../img/icon-eye-show.svg");
}

.gigab2b-eye-hide {
    background-image: url("../img/icon-eye-hide.svg");
}

#kc-login,
#kc-form-buttons input[type="submit"],
#kc-passwd-update-form input[name="login"] {
    height: 48px;
    border-radius: 10px;
    border-color: var(--auth-submit-bg);
    background: var(--auth-submit-bg);
    color: #ffffff;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: var(--auth-ui-font-size);
    font-weight: 500;
    line-height: var(--auth-ui-line-height);
    letter-spacing: var(--auth-ui-letter-spacing);
}

#kc-login:hover,
#kc-form-buttons input[type="submit"]:hover,
#kc-passwd-update-form input[name="login"]:hover {
    background: var(--auth-submit-bg-hover);
    border-color: var(--auth-submit-bg-hover);
}

/* Ссылка возврата в продукт. */
.kc-product-link-wrapper {
    margin-top: 12px;
    text-align: center;
}

.kc-product-link {
    color: var(--auth-link);
    font-size: 15px;
    text-decoration: underline;
}

/* Экраны info.ftl и update password оформляем в стиле макета из Figma. */
.gigab2b-flow-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.gigab2b-flow-text {
    margin: 0;
    color: var(--auth-subtitle);
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    letter-spacing: -0.3px;
}

.gigab2b-flow-title-only {
    margin: 0;
    color: var(--auth-title);
    font-family: "SB Sans Display", "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 28px;
    letter-spacing: -0.18px;
}

.gigab2b-primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--auth-submit-bg);
    background: var(--auth-submit-bg);
    color: #ffffff;
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: -0.3px;
    text-decoration: none;
    box-sizing: border-box;
}

.gigab2b-primary-link:hover,
.gigab2b-primary-link:focus {
    background: var(--auth-submit-bg-hover);
    border-color: var(--auth-submit-bg-hover);
    color: #ffffff;
    text-decoration: none;
}

#kc-passwd-update-form .form-group {
    margin-bottom: 16px;
}

#kc-passwd-update-form .form-group:last-child {
    margin-bottom: 0;
}

#kc-update-profile-form .form-group {
    margin-bottom: 16px;
}

#kc-update-profile-form .form-group:last-child {
    margin-bottom: 0;
}

#kc-update-profile-form #kc-form-options {
    display: none;
}

/* Экран update profile: подгоняем карточку и ритм под Figma. */
body[data-page-id="login-update-profile"] .card-pf,
.login-pf-page:has(#kc-update-profile-form) .card-pf {
    width: min(100%, 448px);
    border-radius: 16px;
    padding: 24px;
}

#kc-update-profile-form .form-group {
    margin-bottom: 16px;
}

#kc-update-profile-form .form-group:last-child {
    margin-bottom: 0;
}

#kc-update-profile-form :is(input, .pf-v5-c-form-control) {
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    border-color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: -0.3px;
    padding-inline: 12px;
}

#kc-update-profile-form label {
    color: var(--auth-title);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: -0.3px;
}

/* В макете update profile нет звездочек required, скрываем маркеры только тут. */
#kc-update-profile-form label > span[aria-hidden="true"],
#kc-update-profile-form label .required {
    display: none !important;
}

#kc-update-profile-form #kc-form-buttons {
    margin-top: 24px;
}

#kc-update-profile-form #kc-form-buttons input[type="submit"] {
    height: 36px;
    min-height: 36px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: -0.3px;
}

.gigab2b-update-password-subtitle {
    margin: 0 0 24px;
    color: var(--auth-subtitle);
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 24px;
    letter-spacing: -0.3px;
}

/* Чекбокс сессий выравниваем по макету шага обновления пароля. */
#kc-passwd-update-form .checkbox {
    margin: 0 0 24px;
    color: var(--auth-title);
    font-family: "SB Sans Text", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    letter-spacing: -0.3px;
}

#kc-passwd-update-form .checkbox input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    border: 1px solid #a4a4a4;
    border-radius: 4px;
    background: #ffffff;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
    vertical-align: middle;
    cursor: pointer;
}

/* В Keycloak чекбокс может приходить уже отмеченным. Рисуем галку в фирменном стиле. */
#kc-passwd-update-form .checkbox input[type="checkbox"]:checked {
    border-color: #15171b;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' viewBox='0 0 10 8'%3E%3Cpath d='M1 4L3.8 7L9 1' stroke='%2315171b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px 8px;
}

#kc-passwd-update-form .checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 0 !important;
    cursor: pointer;
}

/* Гасим дефолтные смещения PatternFly, чтобы первая буква не перекрывалась чекбоксом. */
#kc-passwd-update-form .checkbox input[type="checkbox"] {
    position: static !important;
    float: none !important;
    margin-left: 0 !important;
}

/* Этот блок нужен только для страницы обычного логина. */
#kc-form-login #kc-form-options,
#kc-form-login .checkbox,
#kc-form-login #kc-form-options + div {
    font-size: 12px;
}

@media (max-width: 640px) {
    #kc-header {
        left: 16px;
        top: 14px;
    }

    #kc-page-title {
        font-size: 18px;
    }

    .gigab2b-login-subtitle {
        font-size: 16px;
    }

    .card-pf {
        max-width: calc(100% - 18px);
        padding: 16px 14px 14px;
    }

    .gigab2b-flow-text {
        font-size: 15px;
        line-height: 22px;
    }
}
