/* =============================================
   SimplyAdd Keycloak Login
   ============================================= */

:root {
  --sa-primary: #0f4c81;
  --sa-primary-hover: #0a3760;
  --sa-primary-light: #eef5fc;
  --sa-bg-app: #f8fafc;
  --sa-bg-card: #ffffff;
  --sa-border: #e2e8f0;
  --sa-radius-lg: 12px;
  --sa-shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --sa-status-stage2: #c62828;
  --sa-status-stage2-bg: #fdecea;
  --sa-text: #1f2937;
  --sa-muted: #64748b;
}

/* TM Superscript Formatting */
#kc-header-wrapper sup,
.kc-logo-text sup,
.login-pf-header sup,
.tm-mark {
    font-size: 0.42em;
    line-height: 1;
    vertical-align: super;
    position: relative;
    top: -0.10em;
    letter-spacing: 0;
    font-weight: 600;
}

/* 1. CANVAS: Viewport height and centering */
body.login-pf,
.login-pf-page,
.pf-v5-c-login {
    background: var(--sa-bg-app) !important;
    min-height: 100vh !important;
    width: 100% !important;
    max-width: 100% !important;
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif !important;
    color: var(--sa-text) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 1.5rem 1rem !important;
    box-sizing: border-box !important;
}

/* 2. INNER CONTAINERS */
.pf-v5-c-login__container,
#kc-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 680px !important;
}

/* Subtle security indicator below the login card (no template override needed) */
.pf-v5-c-login__container::after,
#kc-container::after {
    content: "🔒 256-Bit Encrypted Session";
    display: block;
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.15px;
    color: var(--sa-muted);
}

/* 3. BRAND HEADER */
#kc-header,
.pf-v5-c-login__header {
    width: 100% !important;
    text-align: center !important;
    margin-bottom: 1rem !important;
    display: block !important;
}

/* Subtitle injected under the brand logo (no template override needed) */
#kc-header::after,
.pf-v5-c-login__header::after {
    content: "Secure Personal Health & Vitals Portal";
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.15px;
    color: var(--sa-muted);
}

#kc-header-wrapper,
.pf-v5-c-brand {
    color: var(--sa-primary) !important;
    font-size: clamp(1.8rem, 3.2vw, 2.2rem) !important;
    font-weight: 500 !important;
    letter-spacing: -0.4px !important;
    text-align: center !important;
    width: 100% !important;
}

/* 4. FORM CARD */
.card-pf,
.pf-v5-c-card,
.pf-v5-c-login__main {
    background: var(--sa-bg-card) !important;
    border: 1px solid var(--sa-border) !important;
    border-radius: var(--sa-radius-lg) !important;
    box-shadow: var(--sa-shadow-md) !important;
    padding: 2.5rem !important;
    width: 100% !important;
    max-width: 680px !important;
    height: auto !important;
    min-height: unset !important;
    box-sizing: border-box !important;
    text-align: left !important;
}

/* Form block sub-title header */
#kc-page-title,
.pf-v5-c-title {
    color: var(--sa-primary) !important;
    font-weight: 500 !important;
    font-size: clamp(1.35rem, 2.7vw, 1.5rem) !important;
    letter-spacing: -0.35px !important;
    text-align: left !important;
    margin-bottom: 1.25rem !important; /* Reduced bottom margin */
    width: 100% !important;
}

/* Strip structural grouping margins to clear air gap */
#kc-form-login .form-group,
.pf-v5-c-login__main-body,
#kc-content-wrapper {
    text-align: left !important;
    width: 100% !important;
    margin-bottom: 0.5rem !important;
    padding-bottom: 0 !important;
}

/* Keycloak.v2's .pf-v5-c-form is a CSS grid with its own default 24px row gap, which
   stacks with (doesn't collapse with) margins below — zero it out so margins are the
   single source of truth for vertical rhythm. */
#kc-form-login,
.pf-v5-c-form {
    gap: 0 !important;
}

/* Compact vertical spacing between form groups (Username -> Password): 8px-grid rhythm */
.pf-v5-c-form__group {
    text-align: left !important;
    width: 100% !important;
    margin-bottom: 1rem !important; /* 16px vertical gap */
    padding-bottom: 0 !important;
}

/* Compact vertical spacing between last input/options and the Submit button */
.pf-v5-c-form__group:last-of-type,
.pf-v5-c-form__group--action,
#kc-form-buttons {
    margin-top: 1.5rem !important; /* 24px vertical gap before action */
}

/* Remove PatternFly's 3D pseudo-element wireframe/bevel overlays on form controls */
.pf-v5-c-form-control::before,
.pf-v5-c-form-control::after,
.pf-v5-c-form-control *::before,
.pf-v5-c-form-control *::after {
    display: none !important;
    content: none !important;
}

/* Form inputs styling — Keycloak wraps each raw <input> in a <span class="pf-v5-c-form-control">,
   so the single visible box lives on that wrapper; see the reset below for the nested <input>. */
.pf-v5-c-form-control,
.form-control {
    display: flex !important;
    align-items: center !important;
    border-radius: 8px !important;
    border: 1px solid #cbd5e1 !important;
    min-height: 44px !important;
    font-size: 1rem !important;
    padding: 10px 14px !important;
    background-color: var(--sa-bg-card) !important;
    box-shadow: none !important;
    outline: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    text-align: left !important;
}

/* The form group above now owns vertical rhythm; the control itself shouldn't add its own */
.pf-v5-c-form-control {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* The nested raw <input> must stay borderless/transparent so it doesn't draw its own box
   on top of the wrapper span above (that was the 3D "wireframe" doubled-border artifact).
   height:auto + line-height (rather than height:100%) lets the flex parent's align-items:center
   vertically center the text/dots instead of the input stretching and sitting on its baseline. */
.pf-v5-c-form-control input,
#username,
#password,
#kc-form input[type="text"],
#kc-form input[type="password"],
#kc-form input[type="email"] {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    line-height: 1.25 !important;
    vertical-align: middle !important;
    font-size: 1rem !important;
}

.pf-v5-c-form-control:focus-within,
.form-control:focus-within {
    border-color: var(--sa-primary) !important;
    box-shadow: 0 0 0 4px var(--sa-primary-light) !important;
    outline: none !important;
}

/* Force password input and visibility toggle button to match height perfectly */
.pf-v5-c-form-control__toggle-button,
.pf-c-input-group__button,
.pf-v5-c-button.pf-m-control,
#kc-form input[type="password"] + button {
    min-height: 44px !important;
    max-height: 44px !important;
    height: 44px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    box-sizing: border-box !important;
}

/* Ensure the outer input-group wrapper (password field + toggle button) matches height;
   NOT .pf-v5-c-form-control itself, which needs align-items:center (set above) to vertically
   center its text, not stretch (stretch was overriding center and causing text/dots to sit low). */
.pf-c-input-group,
.input-group {
    display: flex !important;
    align-items: stretch !important;
    min-height: 44px !important;
    height: 44px !important;
}

/* Ensure the password text field doesn't inherit a stray bottom margin from being inside a group
   (height stays auto — see the borderless-input reset rule above — so text/dots stay centered) */
#kc-form input[type="password"] {
    margin-bottom: 0 !important; /* Let the parent group handle bottom spacing if inside a group */
}

/* Tightly stacked left-aligned input labels */
#kc-form label,
.pf-v5-c-form__label-text {
    font-weight: 500 !important;
    color: var(--sa-text) !important;
    font-size: 0.9rem !important;
    margin-bottom: 0.4rem !important;
    margin-top: 0.75rem !important;
    display: inline-block !important;
    text-align: left !important;
    width: 100% !important;
}

/* Primary Execution Button */
#kc-login,
.pf-v5-c-button.pf-m-primary,
.btn-primary,
input[type="submit"] {
    background: var(--sa-primary) !important;
    border: 1px solid var(--sa-primary) !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    min-height: 44px !important;
    color: #ffffff !important;
    width: 100% !important;
    cursor: pointer !important;
    margin-top: 1.5rem !important;
    text-align: center !important;
    transition: background-color 0.2s ease, border-color 0.2s ease !important;
}

#kc-login:hover,
.pf-v5-c-button.pf-m-primary:hover,
input[type="submit"]:hover {
    background: var(--sa-primary-hover) !important;
    border-color: var(--sa-primary-hover) !important;
}

#kc-info,
#kc-registration,
.login-pf-settings,
.pf-v5-c-login__main-footer-text {
    color: var(--sa-muted) !important;
    text-align: left !important;
    margin-top: 1rem !important;
    width: 100% !important;
    font-size: 0.9rem !important;
}

a {
    color: var(--sa-primary) !important;
    text-decoration: none !important;
}

a:hover {
    color: var(--sa-primary-hover) !important;
    text-decoration: underline !important;
}

.alert,
.pf-v5-c-alert {
    border-radius: 8px !important;
    padding: 10px !important;
}

.alert-error,
.alert-warning,
.pf-v5-c-alert.pf-m-danger,
.pf-v5-c-alert.pf-m-warning,
#kc-error-message {
    background: var(--sa-status-stage2-bg) !important;
    color: var(--sa-status-stage2) !important;
    border: 1px solid var(--sa-status-stage2-bg) !important;
}

.alert-error .pf-v5-c-alert__icon,
.alert-warning .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-danger .pf-v5-c-alert__icon,
.pf-v5-c-alert.pf-m-warning .pf-v5-c-alert__icon {
    color: var(--sa-status-stage2) !important;
}

@media (max-width: 768px) {
    .card-pf,
    .pf-v5-c-card,
    .pf-v5-c-login__main {
        padding: 1.75rem !important;
    }
}
