/*Original CSS at:
    https://github.com/keycloak/keycloak/blob/main/themes/src/main/resources/theme/keycloak/login/resources/css/login.css
*/

/* Import Figtree font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600;700&display=swap');

/* Import Font Awesome for icons - using v5 for better PatternFly compatibility */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css');

/* Import Material Icons as fallback */
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

/* Font Awesome 5 compatibility for Keycloak/PatternFly */
.fa, .fas {
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 900 !important;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  line-height: 1;
}

.far {
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 400 !important;
}

/* Specific fix for password toggle eye icons */
.pf-c-button.pf-m-control i.fa-eye::before {
  content: "\f06e";
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 900 !important;
  font-style: normal;
}

.pf-c-button.pf-m-control i.fa-eye-slash::before {
  content: "\f070";
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 900 !important;
  font-style: normal;
}

/* Ensure Font Awesome icons display properly */
.pf-c-button.pf-m-control i[class*="fa-"] {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
}


/* Material Icons fallback for password toggle */
.pf-c-button.pf-m-control .material-icons {
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga';
}

/* PatternFly icon compatibility */
.pficon-eye::before {
  content: "\f06e";
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 900 !important;
}

.pficon-eye-slash::before {
  content: "\f070";
  font-family: 'Font Awesome 5 Free' !important;
  font-weight: 900 !important;
}



/* Ryse theme overrides to match application theming */
:root {
  --primary: #00269f;
}

* {
  color: #333;
  font-family: 'Figtree', sans-serif !important;
}

body,
.login-pf body {
  background: #ffffff !important;
  --pf-global--BackgroundColor--dark-100: #ffffff;
  --pf-global--BackgroundColor--dark-200: rgb(245, 245, 245);
  --pf-global--Color--100: var(--primary);
}

/* Links */
.login-pf a,
#kc-login span a,
#kc-registration a,
#kc-form-options a {
  color: var(--primary);
}
.login-pf a:hover {
  color: var(--primary);
}

/* Buttons */
#kc-form-buttons .pf-c-button,
#kc-login,
.pf-c-button.pf-m-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  border-radius: 4px;
}

.pf-c-button.pf-m-secondary {
  border-color: rgba(33, 33, 33, 0.08);
  color: var(--primary);
  border-radius: 4px;
}

/* Inputs */
.pf-c-form-control,
#kc-form-login input[type="text"],
#kc-form-login input[type="password"],
#kc-reset-password-form input[type="text"],
#kc-reset-password-form input[type="password"],
#kc-register-form input:not([type="checkbox"]) {
  color: #333;
  border-radius: 4px;
}


.pf-c-form-control::placeholder {
  color: #6b7280;
}

/* Header/logo */
#kc-header, #kc-header-wrapper { color: #333; }
#kc-logo { width: 100%; }

/* Cards/containers */
#kc-form, #kc-content { background: #fff; }
/* End Ryse overrides */
/* Patternfly CSS places a "bg-login.jpg" as the background on this ".login-pf" class.
   This clashes with the "keycloak-bg.png' background defined on the body below.
   Therefore the Patternfly background must be set to none. */
.login-pf {
  background: none;
}

.login-pf body {
  /*background: url("../img/keycloak-bg.png") no-repeat center center fixed;*/
  background: none;
  background-size: cover;
  height: 100%;
}

textarea.pf-c-form-control {
  height: auto;
}

.pf-c-alert__title {
  font-size: var(--pf-global--FontSize--xs);
}

p.instruction {
  margin: 5px 0;
}

.pf-c-button.pf-m-control {
  border-color: rgba(230, 230, 230, 0.5);
}

h1#kc-page-title {
  margin-top: 10px;
}

#kc-locale ul {
  background-color: var(--pf-global--BackgroundColor--100);
  display: none;
  top: 20px;
  min-width: 100px;
  padding: 0;
}

#kc-locale-dropdown {
  display: inline-block;
}

#kc-locale-dropdown:hover ul {
  display: block;
}

#kc-locale-dropdown a {
  color: var(--pf-global--Color--200);
  text-align: right;
  font-size: var(--pf-global--FontSize--sm);
}

#kc-locale-dropdown button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--pf-global--Color--200);
  text-align: right;
  font-size: var(--pf-global--FontSize--sm);
}

button#kc-current-locale-link::after {
  content: '\2c5';
  margin-left: var(--pf-global--spacer--xs);
}

.login-pf .container {
  padding-top: 40px;
}

.login-pf a:hover {
  /*color: #0099d3;*/
  color: #00269f;
}

#kc-logo {
  width: 100%;
}

div.kc-logo-text {
  background-image: url(../img/ryse_logo_TM.svg);
  background-repeat: no-repeat;
  /*height: 63px;
    width: 300px;*/
  height: 69px;
  width: 182px;
  background-size: contain;
  margin: 0 auto;
}

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

#kc-header {
  color: #ededed;
  overflow: visible;
  white-space: nowrap;
  margin-bottom: 10px;
}

#kc-header-wrapper {
  font-size: 29px;
  text-transform: uppercase;
  letter-spacing: 3px;
  line-height: 1.2em;
  padding: 62px 10px 20px;
  white-space: normal;
}

#kc-content {
  width: 100%;
}

#kc-attempted-username {
  font-size: 20px;
  font-family: inherit;
  font-weight: normal;
  padding-right: 10px;
}

#kc-username {
  text-align: center;
  margin-bottom: -10px;
}

#kc-webauthn-settings-form {
  padding-top: 8px;
}

#kc-form-webauthn .select-auth-box-parent {
  pointer-events: none;
}

#kc-form-webauthn .select-auth-box-desc {
  color: var(--pf-global--palette--black-600);
}

#kc-form-webauthn .select-auth-box-headline {
  color: var(--pf-global--Color--300);
}

#kc-form-webauthn .select-auth-box-icon {
  flex: 0 0 3em;
}

#kc-form-webauthn .select-auth-box-icon-properties {
  margin-top: 10px;
  font-size: 1.8em;
}

#kc-form-webauthn .select-auth-box-icon-properties.unknown-transport-class {
  margin-top: 3px;
}

#kc-form-webauthn .pf-l-stack__item {
  margin: -1px 0;
}

#kc-content-wrapper {
  margin-top: 20px;
}

#kc-form-wrapper {
  margin-top: 10px;
}

#kc-info {
  margin: 20px -40px -30px;
}

#kc-info-wrapper {
  font-size: 13px;
  padding: 15px 35px;
  background-color: #f0f0f0;
}

#kc-form-options span {
  display: block;
}

#kc-form-options .checkbox {
  margin-top: 0;
  color: #72767b;
}

#kc-terms-text {
  margin-bottom: 20px;
}

#kc-registration-terms-text {
  max-height: 100px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 5px;
}

#kc-registration {
  margin-bottom: 0;
}

/* TOTP */

.subtitle {
  text-align: right;
  margin-top: 30px;
  color: #909090;
}

.required {
  color: var(--pf-global--danger-color--200);
}

ol#kc-totp-settings {
  margin: 0;
  padding-left: 20px;
}

ul#kc-totp-supported-apps {
  margin-bottom: 10px;
}

#kc-totp-secret-qr-code {
  max-width: 150px;
  max-height: 150px;
}

#kc-totp-secret-key {
  background-color: #fff;
  color: #333333;
  font-size: 16px;
  padding: 10px 0;
}

/* OAuth */

#kc-oauth h3 {
  margin-top: 0;
}

#kc-oauth ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#kc-oauth ul li {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  padding: 10px 0;
}

#kc-oauth ul li:first-of-type {
  border-top: 0;
}

#kc-oauth .kc-role {
  display: inline-block;
  width: 50%;
}

/* Code */
#kc-code textarea {
  width: 100%;
  height: 8em;
}

/* Social */
.kc-social-links {
  margin-top: 20px;
}

.kc-social-links li {
  width: 100%;
}

.kc-social-provider-logo {
  font-size: 23px;
  width: 30px;
  height: 25px;
  float: left;
}

.kc-social-gray {
  color: var(--pf-global--Color--200);
}

.kc-social-gray h2 {
  font-size: 1em;
}

.kc-social-item {
  margin-bottom: var(--pf-global--spacer--sm);
  font-size: 15px;
  text-align: center;
}

.kc-social-provider-name {
  position: relative;
}

.kc-social-icon-text {
  left: -15px;
}

.kc-social-grid {
  display: grid;
  grid-column-gap: 10px;
  grid-row-gap: 5px;
  grid-column-end: span 6;
  --pf-l-grid__item--GridColumnEnd: span 6;
}

.kc-social-grid .kc-social-icon-text {
  left: -10px;
}

.kc-login-tooltip {
  position: relative;
  display: inline-block;
}

.kc-social-section {
  text-align: center;
  position: static !important;
  width: 100% !important;
}

.kc-social-section hr {
  margin-bottom: 10px;
}

/* Fix social providers positioning - Override parent theme */
#kc-social-providers,
div#kc-social-providers,
.kc-social-section#kc-social-providers {
  position: static !important;
  width: 100% !important;
  float: none !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  bottom: auto !important;
  margin-top: 30px !important;
  text-align: center !important;
  transform: none !important;
  display: block !important;
  z-index: auto !important;
}

#kc-social-providers hr {
  margin: 20px 0;
  border-top: 1px solid #DDDDDD;
}

#kc-social-providers h2 {
  font-size: 14px;
  font-weight: 500;
  color: #5E5E5E;
  margin-bottom: 20px;
  text-align: center;
}

#kc-social-providers ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#kc-social-providers li {
  display: block;
  width: 100%;
  margin-bottom: 0;
}

#kc-social-providers .pf-c-button {
  width: 100%;
  background: #fff;
  border: 1px solid #DDDDDD;
  border-radius: 12px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #000;
  font-weight: 500;
}

#kc-social-providers .pf-c-button:hover {
  border-color: #001F7A;
  background-color: rgba(0, 38, 159, 0.05);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 38, 159, 0.1);
}

#kc-social-providers .kc-social-icon-text {
  position: relative;
  left: 0;
  margin-left: 10px;
}

/* Override absolute positioning on social buttons from parent theme */
#kc-social-providers .pf-c-button,
#kc-social-providers .kc-social-item,
#kc-social-providers a[id^="social-"],
#social-google-register,
#social-google-login,
.kc-social-item.kc-social-gray {
  position: static !important;
  width: 100% !important;
  right: auto !important;
  top: auto !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin: 0 0 12px 0 !important;
  max-width: 100% !important;
}

.kc-login-tooltip .kc-tooltip-text {
  top: -3px;
  left: 160%;
  background-color: black;
  visibility: hidden;
  color: #fff;

  min-width: 130px;
  text-align: center;
  border-radius: 2px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
  padding: 5px;

  position: absolute;
  opacity: 0;
  transition: opacity 0.5s;
}

/* Show tooltip */
.kc-login-tooltip:hover .kc-tooltip-text {
  visibility: visible;
  opacity: 0.7;
}

/* Arrow for tooltip */
.kc-login-tooltip .kc-tooltip-text::after {
  content: ' ';
  position: absolute;
  top: 15px;
  right: 100%;
  margin-top: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent black transparent transparent;
}

@media (min-width: 768px) {
  #kc-container-wrapper {
    position: absolute;
    width: 100%;
  }

  .login-pf .container {
    padding-right: 80px;
  }

  #kc-locale {
    position: relative;
    text-align: right;
    z-index: 9999;
  }
}

@media (max-width: 767px) {
  .login-pf body {
    background: white;
  }

  #kc-header {
    padding-left: 15px;
    padding-right: 15px;
    float: none;
    text-align: left;
  }

  #kc-header-wrapper {
    font-size: 16px;
    font-weight: bold;
    padding: 20px 60px 0 0;
    color: #72767b;
    letter-spacing: 0;
    padding-right: 0px;
  }

  div.kc-logo-text {
    margin: 0;
    /*width: 150px;
        height: 32px;*/
    height: 69px;
    width: 182px;
    background-size: contain;
    background-size: 100%;
    margin: auto;
  }

  #kc-form {
    float: none;
  }

  #kc-info-wrapper {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: transparent;
  }

  .login-pf .container {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  #kc-locale {
    position: absolute;
    width: 200px;
    top: 20px;
    right: 20px;
    text-align: right;
    z-index: 9999;
  }
}

@media (min-height: 646px) {
  #kc-container-wrapper {
    bottom: 12%;
  }
}

@media (max-height: 645px) {
  #kc-container-wrapper {
    padding-top: 50px;
    top: 20%;
  }
}

.card-pf form.form-actions .btn {
  float: right;
  margin-left: 10px;
}

#kc-form-buttons {
  margin-top: 20px;
}

.login-pf-page .login-pf-brand {
  margin-top: 20px;
  max-width: 360px;
  width: 40%;
}

.select-auth-box-arrow {
  display: flex;
  align-items: center;
  margin-right: 2rem;
}

.select-auth-box-icon {
  display: flex;
  flex: 0 0 2em;
  justify-content: center;
  margin-right: 1rem;
  margin-left: 3rem;
}

.select-auth-box-parent {
  border-top: 1px solid var(--pf-global--palette--black-200);
  padding-top: 1rem;
  padding-bottom: 1rem;
  cursor: pointer;
  text-align: left;
  align-items: unset;
  background-color: unset;
  border-right: unset;
  border-bottom: unset;
  border-left: unset;
}

.select-auth-box-parent:hover {
  background-color: #f7f8f8;
}

.select-auth-container {
  padding-bottom: 0px !important;
}

.select-auth-box-headline {
  font-size: var(--pf-global--FontSize--md);
  color: var(--pf-global--primary-color--100);
  font-weight: bold;
}

.select-auth-box-desc {
  font-size: var(--pf-global--FontSize--sm);
}

.select-auth-box-paragraph {
  text-align: center;
  font-size: var(--pf-global--FontSize--md);
  margin-bottom: 5px;
}

.card-pf {
  margin: 0 auto;
  box-shadow: var(--pf-global--BoxShadow--lg);
  padding: 0 20px;
  max-width: 500px;
  border-top: 4px solid;
  border-color: var(--pf-global--primary-color--100);
}

/*phone*/
@media (max-width: 767px) {
  .login-pf-page .card-pf {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-top: 0;
    border-top: 0;
    box-shadow: 0 0;
  }

  .kc-social-grid {
    grid-column-end: 12;
    --pf-l-grid__item--GridColumnEnd: span 12;
  }

  .kc-social-grid .kc-social-icon-text {
    left: -15px;
  }
}

.login-pf-page .login-pf-signup {
  display: none;
  font-size: 15px;
  color: #72767b;
}
#kc-content-wrapper .row {
  margin-left: 0;
  margin-right: 0;
}

.login-pf-page.login-pf-page-accounts {
  margin-left: auto;
  margin-right: auto;
}

.login-pf-page .btn-primary {
  margin-top: 0;
}

.login-pf-page .list-view-pf .list-group-item {
  border-bottom: 1px solid #ededed;
}

.login-pf-page .list-view-pf-description {
  width: 100%;
}

#kc-form-login div.form-group:last-of-type,
#kc-register-form div.form-group:last-of-type,
#kc-reset-password-form div.form-group:last-of-type,
#kc-update-profile-form div.form-group:last-of-type,
#kc-update-email-form div.form-group:last-of-type {
  margin-bottom: 0px;
}

.no-bottom-margin {
  margin-bottom: 0;
}

#kc-back {
  margin-top: 5px;
}

/* Recovery codes */
.kc-recovery-codes-warning {
  margin-bottom: 32px;
}
.kc-recovery-codes-warning .pf-c-alert__description p {
  font-size: 0.875rem;
}
.kc-recovery-codes-list {
  list-style: none;
  columns: 2;
  margin: 16px 0;
  padding: 16px 16px 8px 16px;
  border: 1px solid #d2d2d2;
}
.kc-recovery-codes-list li {
  margin-bottom: 8px;
  font-size: 11px;
}
.kc-recovery-codes-list li span {
  color: #6a6e73;
  width: 16px;
  text-align: right;
  display: inline-block;
  margin-right: 1px;
}

.kc-recovery-codes-actions {
  margin-bottom: 24px;
}
.kc-recovery-codes-actions button {
  padding-left: 0;
}
.kc-recovery-codes-actions button i {
  margin-right: 8px;
}

.kc-recovery-codes-confirmation {
  align-items: baseline;
  margin-bottom: 16px;
}

#certificate_subjectDN {
  overflow-wrap: break-word;
}
/* End Recovery codes */


/* Ryse form font-size harmonization to match app form components (pm-to-owner/pm-onboarding) */
html, body {
  font-size: 16px;
  line-height: 1.5;
}

/* Inputs */
#kc-form-login input[type="text"],
#kc-form-login input[type="password"],
#kc-reset-password-form input[type="text"],
#kc-reset-password-form input[type="password"],
#kc-register-form input:not([type="checkbox"]),
.pf-c-form-control {
  font-size: 16px;
  line-height: 1.5;
}

/* Labels */
#kc-form-login label,
#kc-register-form label,
#kc-reset-password-form label,
.pf-c-form__label,
.pf-c-form__label-text,
label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #333;
}

/* Buttons */
#kc-form-buttons .pf-c-button,
#kc-login,
.pf-c-button {
  font-size: 14px;
  line-height: 1.5;
}

/* Helper/Error text */
.pf-c-form__helper-text,
.pf-c-helper-text__item-text,
.kcInputErrorMessage,
#kc-error-message,
#input-error,
.pf-c-alert__title {
  font-size: 12px;
  line-height: 1.4;
}

/* Additional mobile-responsive styles for PM onboarding consistency */
@media (max-width: 767px) {
  /* Ensure card takes full width on mobile */
  .login-pf-page .card-pf {
    padding: 24px 16px;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid #dddddd;
    box-shadow: none;
  }

  /* Container padding adjustments */
  .login-pf .container {
    padding: 16px;
  }

  /* Logo styling for mobile */
  div.kc-logo-text {
    width: 140px;
    height: 53px;
    margin-bottom: 24px;
  }

  /* Page title mobile styling */
  h1#kc-page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    text-align: center;
  }

  /* Form inputs mobile styling - matching PM onboarding */
  #kc-form-login input[type="text"],
  #kc-form-login input[type="password"],
  #kc-form-login input[type="email"],
  #kc-register-form input[type="text"],
  #kc-register-form input[type="password"],
  #kc-register-form input[type="email"],
  #kc-reset-password-form input[type="text"],
  #kc-reset-password-form input[type="password"],
  #kc-reset-password-form input[type="email"],
  .pf-c-form-control {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px; /* Prevents iOS zoom */
    border-radius: 12px;
    border: 1px solid #DDDDDD;
  }

  /* Labels mobile styling */
  .pf-c-form__label,
  #kc-form-login label,
  #kc-register-form label,
  #kc-reset-password-form label,
  label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
  }

  /* Form group spacing */
  .pf-c-form__group,
  .form-group {
    margin-bottom: 20px;
  }

  /* Buttons mobile styling - matching PM onboarding */
  #kc-login,
  #kc-register,
  .pf-c-button.pf-m-primary {
    width: 100%;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
    margin-top: 24px;
  }

  /* Social provider buttons */
  #kc-social-providers {
    margin-top: 24px;
  }

  #kc-social-providers .pf-c-button {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 12px;
  }

  /* Registration form - make side-by-side fields stack */
  #kc-register-form > div[style*="display: flex"] {
    flex-direction: column !important;
    gap: 0 !important;
  }

  #kc-register-form > div[style*="display: flex"] > div {
    width: 100% !important;
    margin-bottom: 20px;
  }

  #kc-register-form > div[style*="display: flex"] > div:last-child {
    margin-bottom: 0;
  }

  /* Error messages mobile */
  .alert-error,
  .pf-c-alert.pf-m-danger {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 8px;
    margin-bottom: 20px;
  }

  #input-error,
  .pf-c-helper-text__item.pf-m-error {
    font-size: 12px;
    margin-top: 4px;
  }

  /* Registration/login toggle */
  #kc-registration-container,
  #kc-info {
    margin-top: 24px;
    padding-top: 24px;
    font-size: 14px;
  }

  #kc-registration a,
  #kc-info-wrapper a {
    font-weight: 600;
  }

  /* Form options (remember me, forgot password) */
  #kc-form-options {
    margin-top: 16px;
    margin-bottom: 16px;
    font-size: 14px;
  }

  /* Checkbox labels */
  .checkbox label {
    font-size: 14px;
    font-weight: normal;
  }

  /* Back button */
  #kc-back {
    display: inline-flex;
    align-items: center;
    font-size: 14px;
    margin-bottom: 20px;
  }

  /* Password visibility button */
  .pf-c-button.pf-m-control {
    right: 12px;
    padding: 0;
  }

  /* Ensure touch targets are at least 44px */
  button,
  .pf-c-button,
  input[type="submit"],
  a.pf-c-button {
    min-height: 44px;
  }

  /* Remove any extra margins */
  #kc-content-wrapper {
    margin-top: 0;
  }

  #kc-form-wrapper {
    margin-top: 0;
  }
}

/* Landscape mobile adjustments */
@media (max-width: 767px) and (orientation: landscape) {
  .login-pf-page .card-pf {
    padding: 20px 16px;
  }

  h1#kc-page-title {
    font-size: 20px;
    margin-bottom: 20px;
  }

  .pf-c-form__group,
  .form-group {
    margin-bottom: 16px;
  }

  #kc-login,
  #kc-register,
  .pf-c-button.pf-m-primary {
    margin-top: 20px;
  }
}

#kc-reset-password-form {
  margin: 0 20px;
}
