/* 
 * CSS для создания минималистичной темы входа, как на вашем примере.
 */

/* 1. Общий фон страницы - светло-серый минималистичный */
body {
    background-color: #f5f5f5 !important; /* Светло-серый фон */
    background-image: none !important; /* Убираем все фоновые изображения */
}

html {
    background-color: #f5f5f5 !important;
    background-image: none !important;
}

.login-pf {
    background-color: #f5f5f5 !important;
    background-image: none !important;
}

.login-pf body {
    background: #f5f5f5 !important;
}

.login-pf-page {
    padding-top: 10px;
}

/* 2. Основной белый контейнер для формы */
#kc-container {
    max-width: 600px !important; /* Ширина контейнера */
}

#kc-container-wrapper {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 40px;
    min-height: 520px; /* Уменьшенная высота */
    overflow: visible;
    box-sizing: border-box;
    width: 100%;
}

/* Увеличенная высота для страницы смены пароля */
#kc-container-wrapper:has(#kc-passwd-update-form) {
    min-height: 560px;
}

/* Увеличенная высота при наличии сообщения на странице логина */
#kc-container-wrapper:has(#kc-form-login):has(.alert-success),
#kc-container-wrapper:has(#kc-form-login):has(.alert-error),
#kc-container-wrapper:has(#kc-form-login):has(.alert-warning),
#kc-container-wrapper:has(#kc-form-login):has(.alert-info) {
    min-height: 610px;
}

#kc-content,
#kc-content-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible;
    display: block;
}

#kc-content > * {
    flex-shrink: 0;
}

/* 3. Убираем стандартный логотип Keycloak */
.login-pf-page .pf-c-brand {
    display: none;
}

/* 4. Заголовок "Login" */
#kc-header-wrapper h1 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 28px;
    font-weight: 600;
    color: #333;
    text-align: left;
    margin-bottom: 25px;
}

/* 5. Убираем лишние отступы и элементы */
#kc-info {
    display: block;
}
#kc-content-wrapper {
    padding: 0; /* Padding теперь в #kc-container-wrapper */
}

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

/* 6. Стили для полей ввода (input) и их названий (label) */
label,
.pf-c-form__label {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    display: block;
    margin-bottom: 8px;
    margin-left: 0 !important;
    padding-left: 0 !important;
    position: static !important;
    left: auto !important;
    transform: none !important;
    text-align: left;
}

.form-control,
.pf-c-form-control {
    width: 100%;
    height: 44px;
    padding: 10px 16px !important;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    box-sizing: border-box;
    margin-left: 0 !important;
}

.form-group,
.pf-c-form__group {
    margin-bottom: 20px; /* Отступ между полями */
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

/* Fix for PatternFly horizontal form layout that causes offset */
.pf-c-form__horizontal-group,
[class*="kcFormGroup"],
[class*="pf-c-form"] {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Reset any negative margins from PatternFly */
.pf-c-form__group-label,
.pf-c-form__group-control {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* ========================================
   Global Form Reset - Fix for offset labels and inputs
   ======================================== */

/* Reset row-based layouts that cause left offset */
#kc-content-wrapper .row,
#kc-form .row,
#kc-passwd-update-form .row,
form .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Reset column-based layouts */
[class*="col-"],
.col-xs-12,
.col-sm-12,
.col-md-12,
.col-lg-12 {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
}

/* Ensure all inputs are properly aligned */
#kc-content-wrapper input[type="text"],
#kc-content-wrapper input[type="password"],
#kc-content-wrapper input[type="email"],
input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100% !important;
    margin-left: 0 !important;
    box-sizing: border-box;
    padding-left: 16px !important;
    padding-right: 16px !important;
}

/* Fix any floating labels or absolute positioning */
#kc-content-wrapper label {
    position: static !important;
    float: none !important;
    width: auto !important;
    text-align: left !important;
    margin-left: 0 !important;
}

/* 7. Скрываем ненужные элементы: "Remember Me" и регистрацию */
#kc-form-options, #kc-registration {
    display: none;
}

/* 8. Контейнер для кнопки "Log in" и ссылок */
#kc-form-buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: 10px;
}

/* 9. Контейнер для ссылок Password reset и Register - вертикально */
.kc-form-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 10px; /* Расстояние между ссылками */
    margin-bottom: 20px; /* Отступ перед кнопкой */
}

.kc-form-links span {
    font-size: 14px;
}

.kc-form-links a {
    color: #2c5b9c;
    text-decoration: none;
}

.kc-form-links a:hover {
    text-decoration: underline;
}

/* 10. Синяя кнопка "Log in" - внизу */
#kc-login {
    background-color: #2c5b9c; /* Фирменный синий цвет */
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 12px 24px;
    text-transform: none; /* Убираем преобразование в заглавные буквы */
    box-shadow: none;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}
#kc-login:hover:not(:disabled) {
    background-color: #244a80; /* Более темный синий при наведении */
}
#kc-login:disabled {
    background-color: #9db3ce; /* Бледно-синий для disabled */
    cursor: not-allowed;
    opacity: 0.6;
}

/* Стили для логотипа */
.logo-container {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 40px;
}

.logo-container a {
    display: inline-block;
    text-decoration: none !important;
    cursor: pointer !important;
    border: none !important;
    outline: none !important;
}

.logo-container .login-logo {
    max-width: 200px; /* Можете изменить размер по необходимости */
    height: auto;
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer !important;
}

.logo-container a:hover .login-logo,
.logo-container .login-logo:hover {
    opacity: 0.8 !important;
    transform: scale(1.02);
}

/* Forgot Password page styles */
#kc-reset-password-form .form-control {
    width: 100%;
    height: 44px;
    padding: 10px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    margin-bottom: 10px;
}

#kc-reset-password-form input[type="submit"] {
    background-color: #2c5b9c !important;
    border: none !important;
    border-radius: 4px !important;
    color: white !important;
    font-size: 16px !important;
    font-weight: bold !important;
    padding: 12px 24px !important;
    width: 100% !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#kc-reset-password-form input[type="submit"]:hover {
    background-color: #244a80 !important;
}

/* General alert message container fixes */
[class*="alert-"],
[class*="pf-c-alert"] {
    display: flex !important;
    align-items: flex-start !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: auto !important;
    flex-shrink: 0 !important;
}

/* Ensure all text content in alerts is visible */
[class*="alert-"] > span:not([class*="icon"]),
[class*="pf-c-alert"] > span:not([class*="icon"]),
[class*="alert-"] span[class*="kc-"],
[class*="pf-c-alert"] span[class*="kc-"] {
    display: block !important;
    flex: 1 !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
}

/* Ensure icon containers don't take text styles */
[class*="alert-"] .pf-c-alert__icon,
[class*="pf-c-alert"] .pf-c-alert__icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 20px !important;
}

/* Success message styles - green color */
.alert-success,
.pf-c-alert.pf-m-success {
    background-color: #e8f5e9 !important; /* Светло-зеленый фон */
    border-left: 3px solid #4caf50 !important; /* Зеленая левая граница */
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    height: auto !important;
    min-height: auto !important;
}

.alert-success .pf-c-alert__title,
.alert-success .kc-feedback-text,
.alert-success span:not(.pf-c-alert__icon):not(.pficon),
.pf-c-alert.pf-m-success .pf-c-alert__title,
.pf-c-alert.pf-m-success .kc-feedback-text,
.pf-c-alert.pf-m-success span:not(.pf-c-alert__icon):not(.pficon) {
    color: #2e7d32 !important; /* Темно-зеленый текст для читаемости */
    font-size: 14px !important;
    font-weight: 500 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    display: block !important;
    flex: 1 !important;
}

/* Success icon color */
.alert-success .pf-c-alert__icon,
.pf-c-alert.pf-m-success .pf-c-alert__icon {
    color: #4caf50 !important;
    flex-shrink: 0 !important;
}

/* Error message styles - red color */
#input-error,
.pf-c-form__helper-text.pf-m-error,
span[id="input-error"],
.kc-feedback-text {
    color: #d32f2f !important; /* Красный цвет для сообщений об ошибках */
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

/* Red border for input fields with errors */
input[aria-invalid="true"],
.form-control[aria-invalid="true"] {
    border-color: #d32f2f !important; /* Красная рамка для полей с ошибками */
}

/* Red icon for error indicators */
.alert-error,
.pf-c-alert.pf-m-danger {
    background-color: #fdecea;
    border-left: 3px solid #d32f2f;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    height: auto !important;
    min-height: auto !important;
}

.alert-error .pf-c-alert__title,
.alert-error .kc-feedback-text,
.alert-error span:not(.pf-c-alert__icon):not(.pficon),
.pf-c-alert.pf-m-danger .pf-c-alert__title,
.pf-c-alert.pf-m-danger .kc-feedback-text,
.pf-c-alert.pf-m-danger span:not(.pf-c-alert__icon):not(.pficon) {
    color: #d32f2f !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    display: block !important;
    flex: 1 !important;
}

.alert-error .pf-c-alert__icon,
.pf-c-alert.pf-m-danger .pf-c-alert__icon {
    color: #d32f2f !important;
    flex-shrink: 0 !important;
}

/* Warning message styles - orange/yellow color */
.alert-warning,
.pf-c-alert.pf-m-warning {
    background-color: #fff3e0;
    border-left: 3px solid #ff9800;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    height: auto !important;
    min-height: auto !important;
}

.alert-warning .pf-c-alert__title,
.alert-warning .kc-feedback-text,
.alert-warning span:not(.pf-c-alert__icon):not(.pficon),
.pf-c-alert.pf-m-warning .pf-c-alert__title,
.pf-c-alert.pf-m-warning .kc-feedback-text,
.pf-c-alert.pf-m-warning span:not(.pf-c-alert__icon):not(.pficon) {
    color: #e65100 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    display: block !important;
    flex: 1 !important;
}

.alert-warning .pf-c-alert__icon,
.pf-c-alert.pf-m-warning .pf-c-alert__icon {
    color: #ff9800 !important;
    flex-shrink: 0 !important;
}

/* Info message styles - blue color */
.alert-info,
.pf-c-alert.pf-m-info {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    height: auto !important;
    min-height: auto !important;
}

.alert-info .pf-c-alert__title,
.alert-info .kc-feedback-text,
.alert-info span:not(.pf-c-alert__icon):not(.pficon),
.pf-c-alert.pf-m-info .pf-c-alert__title,
.pf-c-alert.pf-m-info .kc-feedback-text,
.pf-c-alert.pf-m-info span:not(.pf-c-alert__icon):not(.pficon) {
    color: #1565c0 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    display: block !important;
    flex: 1 !important;
}

.alert-info .pf-c-alert__icon,
.pf-c-alert.pf-m-info .pf-c-alert__icon {
    color: #2196f3 !important;
    flex-shrink: 0 !important;
}

/* OTP Input Styles - Modern 6-digit code input */
.otp-input-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
}

.otp-input {
    width: 50px;
    height: 60px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid #d0d0d0;
    border-radius: 8px;
    background-color: #fff;
    color: #333;
    transition: all 0.2s ease;
    outline: none;
    caret-color: #2c5b9c;
}

.otp-input:focus {
    border-color: #2c5b9c;
    box-shadow: 0 0 0 3px rgba(44, 91, 156, 0.1);
    transform: scale(1.05);
}

.otp-input:not(:placeholder-shown) {
    border-color: #2c5b9c;
    background-color: #f8f9ff;
}

/* Responsive OTP inputs for mobile */
@media (max-width: 480px) {
    .otp-input-container {
        gap: 8px;
    }

    .otp-input {
        width: 42px;
        height: 52px;
        font-size: 20px;
    }
}

/* ========================================
   Update Password Form Styles
   ======================================== */

#kc-passwd-update-form {
    width: 100%;
}

#kc-passwd-update-form .form-group,
#kc-passwd-update-form .pf-c-form__group,
#kc-passwd-update-form [class*="kcFormGroup"] {
    margin-bottom: 20px;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

#kc-passwd-update-form label,
#kc-passwd-update-form .pf-c-form__label,
#kc-passwd-update-form [class*="kcLabel"] {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    display: block;
    margin-bottom: 8px;
    margin-left: 0 !important;
    padding-left: 0 !important;
    position: static !important;
    left: auto !important;
    transform: none !important;
}

#kc-passwd-update-form .form-control {
    width: 100%;
    height: 44px;
    padding: 10px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

#kc-passwd-update-form .form-control:focus {
    border-color: #2c5b9c;
    box-shadow: 0 0 0 3px rgba(44, 91, 156, 0.1);
    outline: none;
}

#kc-passwd-update-form .form-control[aria-invalid="true"] {
    border-color: #d32f2f;
}

#kc-passwd-update-form #input-error-password,
#kc-passwd-update-form #input-error-password-confirm {
    color: #d32f2f;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

#kc-passwd-update-form input[type="submit"],
#kc-passwd-update-form button[type="submit"] {
    width: 100%;
    height: 44px;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#kc-passwd-update-form input[type="submit"]#kc-login {
    background-color: #2c5b9c;
    border: none;
    color: white;
}

#kc-passwd-update-form input[type="submit"]#kc-login:hover {
    background-color: #244a80;
}

#kc-passwd-update-form input[type="submit"]#kc-login:active {
    transform: scale(0.98);
}

#kc-passwd-update-form button[name="cancel-aia"] {
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    color: #333;
}

#kc-passwd-update-form button[name="cancel-aia"]:hover {
    background-color: #e8e8e8;
}

/* ========================================
   Info Page Styles
   ======================================== */

#kc-info-message {
    text-align: left;
}

#kc-info-message .instruction {
    font-size: 15px;
    color: #2c5b9c;
    line-height: 1.5;
    margin-bottom: 15px;
}

#kc-info-message .instruction b {
    font-weight: 600;
    color: #333;
}

#kc-info-message a {
    color: #2c5b9c;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

#kc-info-message a:hover {
    color: #244a80;
    text-decoration: underline;
}

/* ========================================
   Password Strength Indicator (optional)
   ======================================== */

.password-strength {
    margin-top: 8px;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.password-strength-bar.weak {
    width: 25%;
    background-color: #d32f2f;
}

.password-strength-bar.fair {
    width: 50%;
    background-color: #ff9800;
}

.password-strength-bar.good {
    width: 75%;
    background-color: #4caf50;
}

.password-strength-bar.strong {
    width: 100%;
    background-color: #2e7d32;
}

/* ========================================
   Password Toggle Visibility (optional)
   ======================================== */

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: #333;
}

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

@media (max-width: 480px) {
    #kc-container-wrapper {
        padding: 25px 20px;
    }

    #kc-passwd-update-form .form-control {
        height: 48px;
        font-size: 16px;
    }

    #kc-passwd-update-form input[type="submit"],
    #kc-passwd-update-form button[type="submit"] {
        height: 48px;
        font-size: 16px;
    }
}