/* Copyright (c) TRIVIATEC */
/* Calcypher Industrial Blue Login Theme for Keycloak 24+ */

/* ── Page background ──────────────────────────────────── */
.login-pf body,
body.kc-login,
body {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%) !important;
  background-attachment: fixed !important;
  min-height: 100vh !important;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
}

/* ── Outer layout ─────────────────────────────────────── */
.login-pf-page,
.pf-c-login {
  background: transparent !important;
}

.login-pf-page .container,
.pf-c-login__container {
  max-width: 480px !important;
}

/* ── Login card ───────────────────────────────────────── */
.card-pf,
.pf-c-login__main {
  background-color: rgba(30, 41, 59, 0.97) !important;
  border: 1px solid #334155 !important;
  border-radius: 12px !important;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 60px rgba(59, 130, 246, 0.08) !important;
  padding: 2.25rem 2.5rem !important;
}

#kc-content-wrapper {
  background-color: rgba(30, 41, 59, 0.97) !important;
  border: 1px solid #334155 !important;
  border-radius: 12px !important;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 60px rgba(59, 130, 246, 0.08) !important;
  padding: 2.25rem 2.5rem !important;
  max-width: 440px !important;
  margin: 2rem auto !important;
}

/* ── Header / realm name ──────────────────────────────── */
#kc-header,
#kc-header-wrapper,
.pf-c-login__header {
  color: #f1f5f9 !important;
  text-align: center !important;
  padding-bottom: 1.25rem !important;
}

#kc-header-wrapper {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em !important;
}

/* Calcypher wordmark injected via loginTitleHtml */
#kc-page-title {
  color: #e2e8f0 !important;
  font-weight: 600 !important;
  font-size: 1.25rem !important;
}

/* ── Form labels ──────────────────────────────────────── */
.control-label,
label,
.pf-c-form__label {
  color: #cbd5e1 !important;
  font-weight: 500 !important;
  font-size: 0.9rem !important;
}

/* ── Input fields ─────────────────────────────────────── */
.login-pf input[type="text"],
.login-pf input[type="password"],
.login-pf input[type="email"],
input#username,
input#password,
input#email,
.form-control,
.pf-c-form-control {
  background-color: #334155 !important;
  border: 1px solid #475569 !important;
  border-radius: 8px !important;
  color: #f1f5f9 !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.95rem !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.login-pf input[type="text"]:focus,
.login-pf input[type="password"]:focus,
.login-pf input[type="email"]:focus,
input#username:focus,
input#password:focus,
input#email:focus,
.form-control:focus,
.pf-c-form-control:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
  outline: none !important;
  background-color: #3b4f68 !important;
}

/* ── Override PF4 CSS variables that force white on form-control / input-group ──
 *
 * PF4's patternfly.min.css contains this grouped rule (specificity 0,1,0):
 *   .pf-c-form-control, .pf-c-input-group, ... {
 *     --pf-global--BackgroundColor--100: var(--pf-global--BackgroundColor--light-100);
 *   }
 * which cascades into:
 *   --pf-c-form-control--BackgroundColor: var(--pf-global--BackgroundColor--100)  → #fff
 *   --pf-c-input-group--BackgroundColor: var(--pf-global--BackgroundColor--100)   → #fff
 *
 * We must override those CSS variables AND the background-color property directly.
 * Using :root to set globals first, then per-element overrides.
 */

/* 1. Override global PF4 background tokens at :root so any component inheriting them gets dark */
:root {
  --pf-global--BackgroundColor--100: #1e293b !important;
  --pf-global--BackgroundColor--light-100: #334155 !important;
  --pf-global--BackgroundColor--light-200: #334155 !important;
  --pf-global--BackgroundColor--light-300: #475569 !important;
}

/* 2. Re-scope the variables directly on the affected elements at higher specificity */
.login-pf-page .pf-c-form-control,
.login-pf-page .pf-c-input-group,
#kc-form .pf-c-form-control,
#kc-form .pf-c-input-group {
  --pf-global--BackgroundColor--100: #334155;
  --pf-global--BackgroundColor--light-100: #334155;
  --pf-c-form-control--BackgroundColor: #334155;
  --pf-c-input-group--BackgroundColor: #334155;
  --pf-c-form-control--Color: #f1f5f9;
  background-color: #334155 !important;
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

/* 3. Password input-group wrapper & show/hide toggle ─────── */
/* The password field is wrapped in .pf-c-input-group which has a white bg by default */
.pf-c-input-group,
.pf-v5-c-input-group,
.pf-c-input-group__item,
.pf-v5-c-input-group__item,
.pf-c-text-input-group,
.pf-v5-c-text-input-group,
.pf-c-text-input-group__text-input,
.pf-v5-c-text-input-group__text-input,
div[class*="input-group"],
div[class*="form-control"] {
  background-color: #334155 !important;
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

/* Rounded corners on the input-group wrapper so children are clipped correctly */
.pf-c-input-group,
.pf-v5-c-input-group {
  border-radius: 8px !important;
  overflow: hidden !important;
}

/* Password input inside the group — round left corners only */
.pf-c-input-group > .pf-c-form-control,
.pf-c-input-group > input,
.pf-v5-c-input-group > .pf-c-form-control,
.pf-v5-c-input-group > input,
.pf-c-input-group .pf-c-input-group__item:first-child .pf-c-form-control,
.pf-c-input-group .pf-c-input-group__item:first-child input {
  border-top-left-radius: 8px !important;
  border-bottom-left-radius: 8px !important;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

/* Standalone username field (not in an input-group) keeps full rounding */
input#username {
  border-radius: 8px !important;
}

/* Show/hide password toggle button */
.pf-c-button.pf-m-control,
.pf-v5-c-button.pf-m-control,
button[class*="pf-m-control"] {
  background-color: #334155 !important;
  background: #334155 !important;
  border: 1px solid #475569 !important;
  border-left: none !important;
  color: #94a3b8 !important;
  border-radius: 0 8px 8px 0 !important;
}

.pf-c-button.pf-m-control:hover,
.pf-v5-c-button.pf-m-control:hover,
button[class*="pf-m-control"]:hover {
  background-color: #3b4f68 !important;
  background: #3b4f68 !important;
  color: #f1f5f9 !important;
}

/* Browser autofill — override UA yellow/white fill */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #334155 inset !important;
  -webkit-text-fill-color: #f1f5f9 !important;
  caret-color: #f1f5f9 !important;
  transition: background-color 5000s ease-in-out 0s !important;
}

/* Remove any white/light backgrounds that may leak from login main containers */
#kc-form,
#kc-form-wrapper,
#kc-form-login,
#kc-content,
#kc-content-wrapper,
.pf-c-login__main-body,
.pf-v5-c-login__main-body {
  background-color: transparent !important;
  background: transparent !important;
}

/* Placeholder text */
input::placeholder {
  color: #64748b !important;
}

/* ── Primary action button ────────────────────────────── */
input[type="submit"],
.btn-primary,
.pf-c-button.pf-m-primary,
#kc-login {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
  border: none !important;
  border-radius: 8px !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  padding: 0.75rem 1.5rem !important;
  font-size: 1rem !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  width: 100% !important;
  display: block !important;
}

input[type="submit"]:hover,
.btn-primary:hover,
.pf-c-button.pf-m-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.45) !important;
  transform: translateY(-1px) !important;
}

input[type="submit"]:active,
.btn-primary:active,
.pf-c-button.pf-m-primary:active {
  transform: translateY(0) !important;
  box-shadow: none !important;
}

/* ── Secondary / cancel buttons ──────────────────────── */
.btn-default,
.pf-c-button.pf-m-secondary {
  background-color: transparent !important;
  border: 1px solid #475569 !important;
  border-radius: 8px !important;
  color: #94a3b8 !important;
  padding: 0.6rem 1rem !important;
  transition: all 0.2s ease !important;
}

.btn-default:hover,
.pf-c-button.pf-m-secondary:hover {
  border-color: #7dd3fc !important;
  color: #7dd3fc !important;
}

/* ── Links ────────────────────────────────────────────── */
a,
.login-pf a,
.pf-c-login__main-footer a {
  color: #7dd3fc !important;
  text-decoration: none !important;
  transition: color 0.15s ease !important;
}

a:hover {
  color: #bae6fd !important;
  text-decoration: underline !important;
}

/* ── Remember me checkbox ─────────────────────────────── */
.checkbox label,
.checkbox-inline,
.pf-c-check__label {
  color: #94a3b8 !important;
  font-size: 0.88rem !important;
}

/* ── Alert / error messages ───────────────────────────── */
.alert-error,
.alert-danger,
.pf-c-alert.pf-m-danger {
  background-color: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid #ef4444 !important;
  border-radius: 8px !important;
  color: #fca5a5 !important;
  padding: 0.75rem 1rem !important;
  margin-bottom: 1rem !important;
}

.alert-warning,
.pf-c-alert.pf-m-warning {
  background-color: rgba(234, 179, 8, 0.12) !important;
  border: 1px solid #eab308 !important;
  border-radius: 8px !important;
  color: #fde047 !important;
  padding: 0.75rem 1rem !important;
}

.alert-info,
.pf-c-alert.pf-m-info {
  background-color: rgba(59, 130, 246, 0.12) !important;
  border: 1px solid #3b82f6 !important;
  border-radius: 8px !important;
  color: #93c5fd !important;
  padding: 0.75rem 1rem !important;
}

.alert-success,
.pf-c-alert.pf-m-success {
  background-color: rgba(34, 197, 94, 0.12) !important;
  border: 1px solid #22c55e !important;
  border-radius: 8px !important;
  color: #86efac !important;
  padding: 0.75rem 1rem !important;
}

/* ── Social / identity provider buttons ───────────────── */
.zocial,
.pf-c-button.pf-m-block {
  border-radius: 8px !important;
  margin-bottom: 0.5rem !important;
}

/* ── Divider ──────────────────────────────────────────── */
.login-pf .login-divider,
hr {
  border-color: #334155 !important;
  margin: 1.25rem 0 !important;
}

/* ── Keycloak branding suppression ───────────────────── */
#kc-info-wrapper {
  display: none !important;
}

/* ── Footer ───────────────────────────────────────────── */
.kc-footer,
.login-pf-page .login-pf-footer,
.pf-c-login__footer {
  text-align: center !important;
  color: #475569 !important;
  font-size: 0.78rem !important;
  padding-top: 1rem !important;
}

/* ── Form group spacing ───────────────────────────────── */
.form-group,
.pf-c-form__group {
  margin-bottom: 1.1rem !important;
}

/* ── Page vertical centering ──────────────────────────── */
.login-pf-page .container-fluid,
.pf-c-login {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 100vh !important;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
  .card-pf,
  .pf-c-login__main,
  #kc-content-wrapper {
    margin: 1rem !important;
    padding: 1.5rem !important;
    border-radius: 8px !important;
  }
}
