/* Yokogawa OpreX Login Page Styles */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;600&display=swap");

/* Reset and base styles */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  width: 100% !important;
  font-family: "Noto Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  overflow: hidden !important;
}

body.login-pf {
  background: #f5f5f5 !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh !important;
  display: block !important;
}

/* Override Keycloak container */
#kc-container-wrapper,
.login-pf #kc-container-wrapper {
  background: transparent !important;
  width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  display: block !important;
}

#kc-container {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Split screen layout */
.split-container {
  display: flex !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Left side - Brand/Image section */
.brand-section {
  flex-shrink: 0;
  background: linear-gradient(
    135deg,
    #0066cc 0%,
    #004499 50%,
    #002266 100%
  ) !important;
  background-image: url("../img/login_logo.png") !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  width: 41% !important;
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 60px !important;
  overflow: hidden !important;
}

.network-overlay {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background-image: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.1) 50%,
      transparent 100%
    ),
    linear-gradient(
      45deg,
      transparent 0%,
      rgba(255, 255, 255, 0.05) 50%,
      transparent 100%
    ) !important;
  opacity: 0.7 !important;
  pointer-events: none !important;
}

.oprex-logo {
  color: white !important;
  text-align: center !important;
  z-index: 2 !important;
  position: relative !important;
}

.oprex-title {
  font-size: 48px !important;
  font-weight: 300 !important;
  margin-bottom: 10px !important;
  letter-spacing: 2px !important;
  color: white !important;
}

.oprex-subtitle {
  font-size: 24px !important;
  font-weight: 300 !important;
  margin-bottom: 40px !important;
  opacity: 0.9 !important;
  color: white !important;
  line-height: 1.2 !important;
}

.yokogawa-brand {
  font-size: 28px !important;
  font-weight: 600 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  color: white !important;
}

.yokogawa-diamond {
  width: 20px !important;
  height: 20px !important;
  background: #ffd700 !important;
  transform: rotate(45deg) !important;
  display: inline-block !important;
}

/* Right side - Login form */
.login-section {
  flex: 1 !important;
  background: white !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  padding: 60px !important;
  position: relative !important;
  width: 100% !important;
}

.card-pf,
.login-pf .card-pf {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: 100% !important;
  max-width: 500px !important;
  margin: 0 !important;
  padding: 0 !important;
}

.login-pf-header,
#kc-header {
  text-align: center !important;
  margin-bottom: 40px !important;
  padding: 0 !important;
}

.yokogawa-logo {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 12px !important;
  margin-bottom: 20px !important;
}

.yokogawa-text {
  font-size: 32px !important;
  font-weight: 600 !important;
  color: #333 !important;
  letter-spacing: 1px !important;
}

.welcome-text {
  color: #2f78dd !important;
  font-size: 16px !important;
  margin-bottom: 30px !important;
  text-align: center !important;
}

.form-group {
  margin-bottom: 40px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #004f9b;
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  position: absolute;
  top: 0px;
  left: 16px;
  transform: translateY(-100%);
}

.form-group label[arial-invalid="true"] {
  color: #990000 !important;
}

.pf-c-form-control {
  width: 100%;
  border: none !important; /* borderless */
  padding: 0px 16px !important;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.3s ease;
  background: #fff;
  box-sizing: border-box;
  outline: none !important;
  border-bottom: 1px solid #004f9b !important;
  background-repeat: no-repeat;
}

.btn-primary {
  background: #0066cc;
  border: none;
  border-radius: 4px;
  height: 42px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  width: 100%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background: #0052a3;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: #333;
  border: none;
  border-radius: 4px;
  height: 42px;
  font-size: 14px;
  font-weight: 700;
  color: white !important;
  text-decoration: none !important;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.microsoft-icon {
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3QgeD0iMSIgeT0iMSIgd2lkdGg9IjkiIGhlaWdodD0iOSIgZmlsbD0iI0YyNTAyMiIvPgo8cmVjdCB4PSIxMSIgeT0iMSIgd2lkdGg9IjkiIGhlaWdodD0iOSIgZmlsbD0iIzdGQkEwMCIvPgo8cmVjdCB4PSIxIiB5PSIxMSIgd2lkdGg9IjkiIGhlaWdodD0iOSIgZmlsbD0iIzAwQTRFRiIvPgo8cmVjdCB4PSIxMSIgeT0iMTEiIHdpZHRoPSI5IiBoZWlnaHQ9IjkiIGZpbGw9IiNGRkI5MDAiLz4KPC9zdmc+Cg==")
    no-repeat center;
  background-size: contain;
}

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

.alert {
  border-radius: 4px;
  border: none;
  margin-bottom: 20px;
  padding: 12px 16px;
}

.alert-error {
  background-color: #fee;
  color: #c53030;
  border-left: 4px solid #c53030;
}

.alert-warning {
  background-color: #fffbf0;
  color: #b7791f;
  border-left: 4px solid #b7791f;
}

.alert-success {
  background-color: #f0fff4;
  color: #22543d;
  border-left: 4px solid #22543d;
}

.alert-info {
  background-color: #f0f8ff;
  color: #2a69ac;
  border-left: 4px solid #2a69ac;
}

/* Invalid credential state */
/* Red underline on invalid fields, keeping the input overall style clean */
#kc-form-login input[aria-invalid="true"] {
  background-image: none !important; /* remove error icon */
  border-bottom: 1px solid #ff0000 !important;
}

/* Make label red only when input is invalid */
#kc-form-login input[aria-invalid="true"] ~ label,
#kc-form-login label[for="username"][aria-invalid="true"],
#kc-form-login label[for="password"][aria-invalid="true"] {
  color: #cc0000 !important;
}

/* Error messages under inputs */
[id^="input-error-"] {
  display: block !important;
  margin-top: 8px !important;
  color: #cc0000 !important;
  font-size: 14px !important;
}

/* Optionally de-emphasize global alert to match design (avoid duplicate messaging) */
.alert-error {
  background-color: transparent !important;
  border: none !important;
  color: #cc0000 !important;
  padding-left: 0 !important;
}

#kc-form-options {
  margin-top: 15px;
  margin-bottom: 20px;
}

#kc-form-options .checkbox {
  margin-bottom: 15px;
}

#kc-form-options label {
  color: #666;
  font-weight: 400;
  font-size: 14px;
}

#kc-registration {
  margin-top: 20px;
  text-align: center;
}

#kc-registration a {
  color: #0066cc;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

#kc-registration a:hover {
  color: #0052a3;
  text-decoration: underline;
}

#kc-form-buttons {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 60px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .split-container {
    flex-direction: column;
  }

  .brand-section {
    flex: 0 0 40%;
    padding: 40px;
  }

  .login-section {
    flex: 1;
    padding: 40px;
  }

  .oprex-title {
    font-size: 36px;
  }

  .oprex-subtitle {
    font-size: 20px;
  }

  .yokogawa-brand {
    font-size: 24px;
  }
}

@media (max-width: 768px) {
  .brand-section {
    flex: 0 0 30%;
    padding: 20px;
  }

  .login-section {
    padding: 30px 20px;
  }

  .oprex-title {
    font-size: 28px;
  }

  .oprex-subtitle {
    font-size: 16px;
  }

  .yokogawa-brand {
    font-size: 20px;
  }

  .yokogawa-text {
    font-size: 28px;
  }
}

/* Custom error page styles */
#kc-error-message {
  text-align: center;
  padding: 20px 0;
}

#kc-error-message .alert {
  margin-bottom: 20px;
  padding: 15px;
  border-radius: 8px;
  text-align: left;
}

#kc-error-message .kc-form-buttons {
  margin-top: 30px;
}

#kc-error-message p {
  color: #555;
  font-size: 16px;
  line-height: 1.5;
  margin: 20px 0;
}

.btn-primary {
  background: #056fcf !important;
  color: white !important;
  border: 1px solid #007bff !important;
  padding: 10px 24px !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  display: inline-block !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  transition: all 0.2s ease !important;
}

/* Countdown styling */
#countdown {
  font-weight: bold;
  color: #007bff;
}

/* Auto-redirect message styling */
#kc-error-message small {
  color: #666;
  font-size: 14px;
}

@media (min-width: 768px) and (max-width: 1199px) {
  .brand-section {
    display: none !important;
  }

  .card-pf,
  .login-pf .card-pf {
    max-width: 600px !important;
  }
}

/* Image loading optimization to prevent flickering */
.oprex-background {
  background-attachment: fixed !important;
  will-change: auto !important;
  transform: translateZ(0) !important;
}

.yokogawa-logo svg {
  will-change: auto !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

/* Prevent layout shifts during form submission */
.split-container {
  transition: none !important;
}

.brand-section {
  transition: none !important;
}

/* Optimize form rendering */
#kc-form-login {
  will-change: auto !important;
}

/* Preload Microsoft icon */
.microsoft-icon {
  will-change: auto !important;
}

.password-input-wrapper {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
}

.password-toggle-btn {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  padding: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 4px !important;
}

.password-toggle-btn:hover {
  background: none !important;
}

.password-toggle-btn:focus {
  outline: none !important;
}

.eye-icon {
  width: 24px !important;
  height: 24px !important;
  transition: opacity 0.2s ease !important;
}

#kc-form-login input[name="password"] {
  padding-right: 48px !important;
}

.text-center {
  text-align: center;
}

#kc-social-providers {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Change Password Page Styles */
#kc-passwd-update-form {
  width: 100%;
  max-width: 440px;
}

#kc-passwd-update-form .form-group {
  margin-bottom: 40px;
  position: relative;
}

#kc-passwd-update-form .form-group label {
  display: block;
  margin-bottom: 8px;
  color: #004f9b;
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
}

#kc-passwd-update-form .form-group label[aria-invalid="true"] {
  color: #990000 !important;
}

#kc-passwd-update-form .password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

#kc-passwd-update-form input[type="password"],
#kc-passwd-update-form input[type="text"] {
  width: 100%;
  border: none !important;
  padding: 0px 48px 0px 16px !important;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.3s ease;
  background: #fff;
  box-sizing: border-box;
  outline: none !important;
  border-bottom: 1px solid #004f9b !important;
}

#kc-passwd-update-form input[aria-invalid="true"] {
  background-image: none !important;
  border-bottom: 1px solid #ff0000 !important;
}

#kc-passwd-update-form .password-toggle-btn {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  padding: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 4px !important;
}

#kc-passwd-update-form .password-toggle-btn:hover {
  background: none !important;
  opacity: 0.7;
}

#kc-passwd-update-form .password-toggle-btn:focus {
  outline: none !important;
}

#kc-passwd-update-form .eye-icon {
  width: 24px !important;
  height: 24px !important;
  transition: opacity 0.2s ease !important;
}

#kc-passwd-update-form .kcInputErrorMessageClass,
#kc-passwd-update-form [class*="input-error"] {
  display: block;
  margin-top: 8px;
  color: #ff0000;
  font-size: 14px;
  font-weight: 400;
}

/* Password Rules Section */
.password-rules {
  margin-bottom: 40px;
  background: transparent;
}

.rules-title {
  font-family: "Noto Sans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #00091a;
  line-height: 1.6;
  margin-bottom: 8px;
  margin-top: 0;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.rule-item .rule-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 3px;
}

.rule-item .rule-icon path {
  fill: #34414d;
  transition: fill 0.3s ease;
}

.rule-item .rule-text {
  flex: 1;
  font-family: "Noto Sans", sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: #183432;
  line-height: 1.6;
  transition: color 0.3s ease;
}

.rule-item.valid .rule-icon path {
  fill: #22c55e !important;
}

.rule-item.valid .rule-text {
  color: #183432;
}

/* Update button styling for change password */
#kc-passwd-update-form .btn-primary {
  background: #056fcf !important;
  border: none !important;
  border-radius: 4px !important;
  height: 42px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: white !important;
  width: 100% !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  padding: 8px 16px !important;
}

#kc-passwd-update-form .btn-primary:hover {
  background: #0052a3 !important;
  transform: translateY(-1px);
}

#kc-passwd-update-form .btn-primary:active {
  transform: translateY(0);
}

#kc-passwd-update-form .btn-primary:disabled {
  background: #ccc !important;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Adjust welcome text for change password page */
#kc-passwd-update-form ~ .welcome-text,
.login-section .welcome-text {
  color: #2f78dd !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  text-align: center !important;
  margin-bottom: 60px !important;
}

/* Responsive adjustments for change password */
@media (max-width: 768px) {
  #kc-passwd-update-form {
    max-width: 100%;
  }

  .password-field {
    margin-bottom: 32px;
  }

  .password-rules {
    margin-bottom: 32px;
  }
}
