/* BaKIM Custom Keycloak Theme */

@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@300;400;500;700&display=swap');

:root {
  --bakim-primary: #003782;
  --bakim-primary-dark: #002c6f;
  --bakim-primary-light: #5c7dc5;
  --bakim-accent: #e91e63;
  --bakim-warn: #CA224A;
  --bakim-text: #212121;
  --bakim-text-secondary: #757575;
  --bakim-background: #fafafa;
  --bakim-header-bg: #0f2d49;
  --bakim-content-max-width: 1200px;
}

/* Reset any default margins */
* {
  box-sizing: border-box;
}

/* Override base font */
body, html {
  font-family: 'Rubik', "Helvetica Neue", sans-serif !important;
  background-color: var(--bakim-background);
  margin: 0 !important;
  padding: 0 !important;
}

/* ========================================
   HEADER - Match frontend header style
   ======================================== */
#kc-header {
  background-color: var(--bakim-header-bg);
  padding: 16px 24px;
  margin: 0;
  width: 100%;
  color: white;
}

#kc-header a,
#kc-header span,
#kc-header h1,
#kc-header-wrapper {
  color: white !important;
}

#kc-header-wrapper {
  max-width: var(--bakim-content-max-width);
  margin: 0 auto;
  padding: 0;
}

/* Brand styling with logo via CSS */
.bakim-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  font-size: 24px;
  color: white;
  letter-spacing: 0.5px;
  font-family: 'Rubik', sans-serif;
}

.bakim-brand::before {
  content: '';
  display: block;
  width: 44px;
  height: 44px;
  background: url('../img/bakim-logo-hexagon.svg') no-repeat center center;
  background-size: contain;
  flex-shrink: 0;
}

/* Hide any default text styling */
.kc-logo-text {
  display: none !important;
}

/* ========================================
   PAGE LAYOUT - Remove double card effect
   ======================================== */
.login-pf-page {
  background-color: white !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* Remove the outer card styling */
.card-pf {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Main content area - white background */
#kc-content {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 24px 120px;
  background-color: white !important;
  margin-bottom: 52px; /* Space for fixed footer */
}

/* The actual login form card */
#kc-content-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 40px;
  max-width: 480px;
  width: 100%;
  position: relative;
}

/* ========================================
   LOGO OPTIONS (for testing)
   ======================================== */

/* Option 2: Form card logo - above title */
.form-card-logo {
  display: block;
  width: 80px;
  height: auto;
  margin: 0 auto 24px auto;
}

/* Option 3: Background watermark - bottom right corner */
#kc-content::after {
  content: '';
  position: fixed;
  bottom: 80px;
  right: 40px;
  width: 200px;
  height: 200px;
  background: url('../img/bakim-logo-hexagon.svg') no-repeat center center;
  background-size: contain;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
}

/* Remove any creamy/gray background from form sections */
.login-pf-header,
#kc-form,
#kc-form-wrapper,
#kc-form-login,
.form-group {
  background: transparent !important;
}

/* ========================================
   LANGUAGE SWITCHER - HIDDEN
   Language is determined by browser settings
   ======================================== */
#kc-locale,
.login-pf-header {
  display: none !important;
}

/* ========================================
   FOOTER - Aligned with content width
   ======================================== */
.login-pf-page::after {
  content: '';
  display: block;
  background-color: var(--bakim-header-bg);
  height: 52px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Centered copyright text */
body::after {
  content: '© 2025 Stadtverwaltung Bamberg';
  display: block;
  color: white;
  font-size: 13px;
  font-family: 'Rubik', sans-serif;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--bakim-content-max-width);
  padding: 0 24px;
  z-index: 10;
}

/* ========================================
   FORM STYLING
   ======================================== */
.pf-c-form-control,
input.pf-c-form-control,
#kc-reset-password-form input[type="text"],
#kc-form input[type="text"],
#kc-form input[type="password"],
#kc-form input[type="email"] {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 12px;
  font-family: 'Rubik', sans-serif;
  transition: border-color 0.3s ease;
  background: white !important;
  width: 100% !important;
  box-sizing: border-box;
}

/* Input wrappers full width */
.pf-c-form__group,
.kc-form-group {
  width: 100%;
}

/* Reset password form - make all elements same width */
#kc-reset-password-form .pf-c-form__group {
  display: block;
}

#kc-reset-password-form .pf-c-form__group > div {
  width: 100% !important;
  max-width: 100% !important;
  flex: none !important;
  padding: 0 !important;
}

.pf-c-form-control:focus {
  border-color: var(--bakim-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 55, 130, 0.1);
}

/* Labels */
.pf-c-form__label,
.pf-c-form__label-text {
  font-family: 'Rubik', sans-serif;
  color: var(--bakim-text);
  font-weight: 500;
  margin-bottom: 6px;
}

/* Keep required asterisk inline with label text */
.pf-c-form__label {
  display: inline !important;
}

.pf-c-form__label-required {
  display: inline !important;
  margin-left: 4px;
}

/* Form buttons container - match input field width */
#kc-form-buttons {
  padding: 0;
  margin-top: 16px;
}

#kc-reset-password-form #kc-form-buttons,
#kc-reset-password-form #kc-form-options {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}

/* Primary button */
#kc-form-buttons .pf-c-button.pf-m-primary,
.pf-c-button.pf-m-primary {
  background-color: var(--bakim-primary);
  border-color: var(--bakim-primary);
  color: white;
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 4px;
  text-transform: none;
  font-family: 'Rubik', sans-serif;
  transition: background-color 0.3s ease;
  width: 100%;
  box-sizing: border-box;
}

#kc-form-buttons .pf-c-button.pf-m-primary:hover,
.pf-c-button.pf-m-primary:hover {
  background-color: var(--bakim-primary-dark);
  border-color: var(--bakim-primary-dark);
}

/* Links */
a {
  color: var(--bakim-primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--bakim-primary-dark);
  text-decoration: underline;
}

/* Alert messages */
.pf-c-alert.pf-m-danger {
  background-color: #fff5f5;
  border-left: 4px solid var(--bakim-warn);
}

.pf-c-alert.pf-m-success {
  background-color: #f0fdf4;
  border-left: 4px solid #4caf50;
}

.pf-c-alert.pf-m-info {
  background-color: #eff6ff;
  border-left: 4px solid var(--bakim-primary);
}

/* ========================================
   ERROR MESSAGES - Red font color
   ======================================== */
/* Form validation error messages - all Keycloak error patterns */
.pf-c-form__helper-text.pf-m-error,
.pf-c-helper-text__item.pf-m-error,
.pf-c-helper-text__item-text,
.kc-feedback-text,
span.pf-c-form__helper-text,
.input-error,
[id^="input-error"],
.pf-m-error .pf-c-helper-text__item-text,
.pf-c-form__helper-text--error,
span[id^="input-error-"],
.pf-c-form-control__error-text,
.error-message {
  color: var(--bakim-warn) !important;
  font-weight: 500;
}

/* Error icon color */
.pf-c-form__helper-text.pf-m-error .pf-c-form__helper-text-icon,
.pf-c-helper-text__item.pf-m-error .pf-c-helper-text__item-icon,
.pf-c-helper-text__item-icon {
  color: var(--bakim-warn) !important;
}

/* Input field error border */
.pf-c-form-control[aria-invalid="true"],
.pf-c-form-control.pf-m-error,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--bakim-warn) !important;
}

/* Alert error text */
.pf-c-alert.pf-m-danger .pf-c-alert__title,
.pf-c-alert.pf-m-danger .pf-c-alert__description,
.alert-error {
  color: var(--bakim-warn) !important;
}

/* ========================================
   REQUIRED FIELD INDICATOR
   ======================================== */
/* Show "* erforderlich" text below terms checkbox */
#kc-form-options .pf-c-check:has(input[name="termsAccepted"])::after,
.pf-c-check:has(#termsAccepted)::after,
#termsAccepted-form-group::after {
  content: "* erforderlich";
  display: block;
  font-size: 13px;
  color: var(--bakim-text-secondary);
  margin-top: 8px;
  font-style: italic;
}

/* Registration link */
#kc-registration {
  margin-top: 24px;
  text-align: center;
}

#kc-registration span {
  color: var(--bakim-text-secondary);
  margin-right: 8px;
}

/* Remember me / Forgot password row */
.pf-c-check__label {
  font-family: 'Rubik', sans-serif;
  color: var(--bakim-text);
}

#kc-form-options {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin: 16px 0;
  padding: 0;
}

#kc-form-options .pf-c-form__actions,
.kc-form-options-wrapper {
  padding: 0;
  margin: 0;
  text-align: left;
}

/* Footer info text */
#kc-info {
  margin-top: 24px;
  text-align: center;
}

#kc-info-wrapper {
  color: var(--bakim-text-secondary);
  font-size: 14px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  #kc-header {
    padding: 12px 16px;
  }

  #kc-content {
    padding: 40px 16px 140px;
    margin-bottom: 52px;
  }

  #kc-content-wrapper {
    padding: 24px;
  }

  body::after {
    padding: 0 16px;
    font-size: 12px;
  }
}
