/* PURPOSE: CSNOL branding overrides for the Keycloak login theme. */
/* PURPOSE: Applies CSNOL design tokens (colors, fonts, form styling) on top of the default keycloak theme. */

/*
 * CSNOL Design Tokens (from csnonline_public_html/CSS/main.css):
 *
 * Colors:
 *   --color-red:        #D1232A  (brand primary)
 *   --color-black:      #000000
 *   --color-white:      #FFFFFF
 *   --color-grey:       #7A7C7F
 *   --color-grey-light: #D9D9D9
 *   --color-grey-bg:    #F2F2F2
 *
 * Font: "Open Sans", sans-serif (Google Fonts, weights 400/600/700)
 *
 * Login card:  whitesmoke (#F5F5F5), border-radius 21px, 1px solid #D1232A,
 *              box-shadow 8px 8px 25px rgba(0,0,0,0.1), max-width 400px
 * Inputs:      border-radius 21px, 1px solid #ccc, padding 10px,
 *              font-size 14px, font-weight 600
 * Button:      border-radius 50px (pill), bg #D1232A, color #FFF,
 *              font-size 16px, box-shadow 7px 7px 13.7px rgba(0,0,0,0.25)
 * Button hover: bg #FFF, color #7A7C7F, border 1px solid #7A7C7F
 * Links:       color #000, underline, font-size 14px, font-weight 600
 * Heading:     font-size 28px, font-weight 500, centered
 */

/* ============================================================
   1. Font Import (fallback if <link> in template.ftl fails)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap');

/* ============================================================
   2. CSS Variable Overrides
   ============================================================ */
:root {
    /* CSNOL brand colors mapped to PatternFly variables */
    --pf-global--primary-color--100: #D1232A;
    --pf-global--primary-color--200: #a9151b;
    --pf-global--link--Color: #000000;
    --pf-global--link--Color--hover: #D1232A;
    --pf-global--FontFamily--sans-serif: "Open Sans", sans-serif;

    /* CSNOL custom properties */
    --csnol-red: #D1232A;
    --csnol-black: #000000;
    --csnol-white: #FFFFFF;
    --csnol-grey: #7A7C7F;
    --csnol-grey-light: #D9D9D9;
    --csnol-grey-bg: #F2F2F2;
    --csnol-card-bg: #F5F5F5;
    --csnol-font: "Open Sans", sans-serif;
}

/* ============================================================
   3. Page-Level Styles
   ============================================================ */

/* Remove default Keycloak background image */
html.login-pf {
    background: var(--csnol-white);
}

.login-pf body,
.login-pf {
    background: var(--csnol-white) !important;
    font-family: var(--csnol-font);
    color: var(--csnol-black);
}

/* ============================================================
   4. Header / Logo Area
   ============================================================ */
#kc-header {
    padding: 0;
    overflow: visible;
}

#kc-header-wrapper {
    /* Hide the default realm text title — we show the logo instead */
    font-size: 0;
    padding: 30px 10px 10px;
    text-align: center;
    color: transparent;
    text-transform: none;
    letter-spacing: 0;
}

/* CSNOL logo displayed via <img> in template.ftl */
.csnol-logo {
    display: block;
    max-width: 300px;
    height: auto;
    margin: 0 auto;
}

/* Hide the default Keycloak logo background (not used, kept as fallback) */
div.kc-logo-text {
    background-image: none;
    height: auto;
    width: auto;
}

div.kc-logo-text span {
    display: none;
}

/* ============================================================
   5. Login Card Container
   ============================================================ */
.card-pf {
    background-color: var(--csnol-card-bg);
    border: 1px solid var(--csnol-red);
    border-top: 1px solid var(--csnol-red);
    border-radius: 21px;
    box-shadow: 8px 8px 25px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    padding: 20px;
    margin: 10px auto 0;
}

/* ============================================================
   6. Page Title
   ============================================================ */

/* Keycloak wraps the page title in a col-md-10 which is narrower than the
   col-md-12 used for the subtitle above it, causing the centered heading
   text to appear shifted left. Force full width to match. */
.login-pf-header .col-md-10 {
    width: 100%;
    float: none;
}

h1#kc-page-title {
    font-family: var(--csnol-font);
    font-size: 28px;
    font-weight: 500;
    text-align: center;
    color: var(--csnol-black);
    margin-top: 10px;
    margin-bottom: 15px;
    line-height: 121.5%;
}

/* ============================================================
   7. Form Header
   ============================================================ */
.login-pf-header {
    text-align: center;
}

/* ============================================================
   8. Form Inputs
   ============================================================ */
.pf-c-form-control,
input.pf-c-form-control,
#kc-form-login input[type="text"],
#kc-form-login input[type="password"],
#kc-form-login input[type="email"] {
    font-family: var(--csnol-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--csnol-black);
    padding: 0 10px;
    border: 1px solid #ccc;
    border-radius: 21px;
    height: 43px;
    line-height: 43px;
    box-sizing: border-box;
    background-color: var(--csnol-white);
    transition: border-color 0.2s ease;
}

.pf-c-form-control:focus,
input.pf-c-form-control:focus {
    border-color: var(--csnol-red);
    outline: none;
    box-shadow: 0 0 0 1px var(--csnol-red);
}

/* Label styling */
.pf-c-form__label,
.pf-c-form__label-text,
label.pf-c-form__label {
    font-family: var(--csnol-font);
    font-weight: 600;
    font-size: 14px;
    color: var(--csnol-black);
    margin-bottom: 5px;
}

/* Password visibility toggle — style as a single bordered unit */
.pf-c-input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid #ccc;
    border-radius: 21px;
    background-color: var(--csnol-white);
    overflow: hidden;
}

#kc-form-login .pf-c-input-group .pf-c-form-control,
.pf-c-input-group input.pf-c-form-control {
    border: none;
    border-radius: 0;
    flex: 1;
    box-shadow: none;
}

#kc-form-login .pf-c-input-group .pf-c-form-control:focus,
.pf-c-input-group input.pf-c-form-control:focus {
    border: none;
    box-shadow: none;
}

.pf-c-input-group:focus-within {
    border-color: var(--csnol-red);
    box-shadow: 0 0 0 1px var(--csnol-red);
}

.pf-c-input-group .pf-c-button.pf-m-control {
    border: none;
    border-radius: 0;
    background-color: var(--csnol-white);
    color: var(--csnol-grey);
    padding: 0 12px;
}

.pf-c-input-group .pf-c-button.pf-m-control:hover {
    color: var(--csnol-red);
}

/* Remove PatternFly's separator/border on toggle button pseudo-element */
.pf-c-input-group .pf-c-button.pf-m-control::after {
    border: none;
}

/* ============================================================
   9. Submit Button
   ============================================================ */
.pf-c-button.pf-m-primary,
#kc-login,
input#kc-login {
    font-family: var(--csnol-font);
    font-size: 16px;
    font-weight: 600;
    color: var(--csnol-white);
    background-color: var(--csnol-red);
    border: 1px solid var(--csnol-red);
    border-radius: 50px;
    padding: 9px 20px;
    cursor: pointer;
    box-shadow: 7px 7px 13.7px rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
    width: 100%;
    display: block;
    text-align: center;
    text-decoration: none;
    margin-top: 15px;
}

.pf-c-button.pf-m-primary:hover,
#kc-login:hover,
input#kc-login:hover {
    background-color: var(--csnol-white);
    color: var(--csnol-grey);
    border: 1px solid var(--csnol-grey);
}

.pf-c-button.pf-m-primary:focus,
#kc-login:focus,
input#kc-login:focus {
    outline: 2px solid var(--csnol-red);
    outline-offset: 2px;
}

/* Secondary / Cancel buttons.
   .btn-default is what the legacy keycloak parent theme maps kcButtonDefaultClass to,
   used by extension form templates (e.g. email-code-form.ftl). */
.pf-c-button.pf-m-secondary,
.pf-c-button.btn-default {
    font-family: var(--csnol-font);
    font-size: 16px;
    font-weight: 600;
    color: var(--csnol-grey);
    background-color: var(--csnol-white);
    border: 1px solid var(--csnol-grey);
    border-radius: 50px;
    padding: 9px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: block;
    text-align: center;
    margin-top: 10px;
}

.pf-c-button.pf-m-secondary:hover,
.pf-c-button.btn-default:hover {
    color: var(--csnol-red);
    border-color: var(--csnol-red);
}

/* ============================================================
   10. Links
   ============================================================ */
.login-pf a,
#kc-form-options a,
#kc-info a,
#kc-registration a {
    color: var(--csnol-black);
    text-decoration: underline;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--csnol-font);
}

.login-pf a:hover,
#kc-form-options a:hover,
#kc-info a:hover,
#kc-registration a:hover {
    color: var(--csnol-black);
    text-decoration: none;
}

/* "Forgot password?" link area */
#kc-form-options {
    text-align: center;
    margin-top: 10px;
}

/* Registration / signup info area */
#kc-info-wrapper {
    font-family: var(--csnol-font);
    font-size: 14px;
    font-weight: 600;
    background-color: transparent;
    text-align: center;
    padding: 15px 20px;
    color: var(--csnol-black);
}

.login-pf-signup {
    font-size: 14px;
    color: var(--csnol-black);
}

#kc-info {
    margin: 10px 0 0;
}

/* First-time login hint (directs migrated users to the password reset flow) */
.csnol-login-hint {
    font-family: var(--csnol-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--csnol-black);
    background-color: #f0f6fc;
    border: 1px solid #ccc;
    border-left: 3px solid #0066cc;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
    text-align: left;
}

/* ============================================================
   11. Alert / Error Messages
   ============================================================ */
.pf-c-alert {
    font-family: var(--csnol-font);
    border: 1px solid #ccc;
    border-radius: 10px;
    margin-bottom: 15px;
}

.pf-c-alert.pf-m-danger,
.alert-error.pf-c-alert {
    border-left: 3px solid var(--csnol-red);
    background-color: #fff5f5;
}

.pf-c-alert.pf-m-warning {
    border-left: 3px solid #f0ad4e;
    background-color: #fdf6ec;
}

.pf-c-alert.pf-m-success {
    border-left: 3px solid #3e8635;
}

.pf-c-alert.pf-m-info {
    border-left: 3px solid #0066cc;
}

.pf-c-alert__title {
    font-family: var(--csnol-font);
    font-size: 14px;
    font-weight: 600;
}

/* Field-level error messages */
.pf-c-form__helper-text.pf-m-error,
.kc-feedback-text {
    font-family: var(--csnol-font);
    color: var(--csnol-red);
    font-size: 13px;
    font-weight: 600;
}

/* ============================================================
   12. Form Options / Remember Me
   ============================================================ */
.login-pf-settings {
    font-family: var(--csnol-font);
}

.login-pf-settings .checkbox label {
    font-family: var(--csnol-font);
    font-size: 14px;
    color: var(--csnol-grey);
}

/* ============================================================
   13. Locale Selector
   ============================================================ */
#kc-locale-dropdown button {
    font-family: var(--csnol-font);
    color: var(--csnol-grey);
}

/* Hide locale dropdown by default, show only when toggled */
#kc-locale-dropdown .pf-c-dropdown__menu {
    display: none;
}

#kc-locale-dropdown button[aria-expanded="true"] + .pf-c-dropdown__menu {
    display: block;
}

#kc-locale-dropdown a {
    font-family: var(--csnol-font);
    color: var(--csnol-black);
}

/* ============================================================
   14. Mobile Responsiveness
   ============================================================ */
@media (max-width: 767px) {
    .login-pf body,
    .login-pf {
        background: var(--csnol-white) !important;
    }

    .card-pf,
    .login-pf-page .card-pf {
        max-width: none;
        margin: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding: 15px;
    }

    #kc-header-wrapper {
        padding: 15px 10px 5px;
        color: transparent;
    }

    .csnol-logo {
        max-width: 200px;
    }

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

@media (min-width: 768px) and (max-width: 1024px) {
    .card-pf {
        max-width: 400px;
    }
}

/* ============================================================
   15. Miscellaneous Overrides
   ============================================================ */

/* Ensure the login container is centered properly */
.login-pf .container {
    padding-top: 20px;
}

/* Form group spacing */
.form-group {
    margin-bottom: 12px;
}

/* Remove the default top border color override from parent theme */
.card-pf {
    border-color: var(--csnol-red);
}

/* Try another way link */
#try-another-way {
    font-family: var(--csnol-font);
    color: var(--csnol-black);
    text-decoration: underline;
    font-weight: 600;
}

#try-another-way:hover {
    text-decoration: none;
}

/* Credential selector ("Zkusit jiným způsobem") — stock template ships
   unstyled buttons; give them card-like appearance matching the form theme. */
.select-auth-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.select-auth-box-parent {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid var(--csnol-grey, #d2d2d2);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-family: var(--csnol-font);
    color: var(--csnol-black);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.select-auth-box-parent:hover,
.select-auth-box-parent:focus {
    border-color: var(--csnol-red, #e30613);
    box-shadow: 0 0 0 1px var(--csnol-red, #e30613);
    background: #fafafa;
    outline: none;
}

.select-auth-box-parent .select-auth-box-icon {
    flex: 0 0 auto;
    margin-right: 18px;
    color: var(--csnol-red, #e30613);
    font-size: 24px;
    min-width: 32px;
    text-align: center;
}

.select-auth-box-parent .select-auth-box-headline {
    font-size: 16px;
    font-weight: 600;
    color: var(--csnol-black);
    margin-bottom: 2px;
}

.select-auth-box-parent .select-auth-box-desc {
    font-size: 13px;
    color: #6a6e73;
    font-weight: 400;
}

.select-auth-box-parent .select-auth-box-arrow {
    flex: 0 0 auto;
    margin-left: 12px;
    color: #6a6e73;
}

.select-auth-box-parent .pf-l-split__item.pf-m-fill {
    flex: 1 1 auto;
}

