/* CyberFrame Security Platform - Keycloak Login Theme */

:root {
  /* Primary Colors - CyberFrame Purple */
  --cf-primary: 265 65% 46%;
  --cf-primary-foreground: 0 0% 100%;
  --cf-secondary: 265 30% 55%;
  --cf-secondary-foreground: 0 0% 100%;

  /* Neutral Colors */
  --cf-background: 0 0% 100%;
  --cf-foreground: 222 84% 5%;
  --cf-muted: 240 5% 96%;
  --cf-muted-foreground: 240 4% 46%;

  /* Semantic Colors */
  --cf-success: 142 71% 45%;
  --cf-warning: 38 92% 50%;
  --cf-error: 0 84% 60%;
  --cf-info: 199 89% 48%;

  /* Borders and Shadows */
  --cf-border: 214 32% 91%;
  --cf-ring: 265 65% 46%;
  --cf-shadow: 222 84% 5% / 0.05;

  /* Spacing */
  --cf-radius: 0.5rem;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --cf-primary: 265 65% 70%;
    --cf-background: 222 47% 11%;
    --cf-foreground: 0 0% 98%;
    --cf-muted: 265 20% 16%;
    --cf-muted-foreground: 240 4% 65%;
    --cf-border: 265 20% 22%;
    --cf-shadow: 0 0% 0% / 0.2;
  }
}

/* ----------------------------------------------------------------
   PF5 Layout Overrides — single centred column
   ---------------------------------------------------------------- */
.pf-v5-c-login {
  min-height: 100vh;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.pf-v5-c-login__container {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  grid-template-columns: 1fr !important;
  max-width: 640px !important;
}

.pf-v5-c-login__main {
  max-width: 640px !important;
  width: 100% !important;
  flex: none !important;
}

/* Hide the PF5 header brand bar and side panel */
#kc-header,
.pf-v5-c-login__header {
  display: none !important;
}

.pf-v5-c-login__aside {
  display: none !important;
}

.pf-v5-c-login__footer {
  display: none !important;
}

/* Reset the h1 wrapper around our custom header content */
#kc-page-title {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  padding: 0;
  line-height: normal;
}

/* Reduce the gap between header (logo) and body (form) */
.pf-v5-c-login__main-header {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.pf-v5-c-login__main-body {
  width: 100%;
  padding-top: 0.5rem !important;
}

/* ----------------------------------------------------------------
   Card Container
   ---------------------------------------------------------------- */
#kc-content {
  background: hsl(var(--cf-background));
  border: 1px solid hsl(var(--cf-border));
  border-radius: calc(var(--cf-radius) * 1.5);
  box-shadow:
    0 10px 15px -3px hsl(var(--cf-shadow)),
    0 4px 6px -2px hsl(var(--cf-shadow));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2.5rem;
  position: relative;
  backdrop-filter: blur(10px);
}

#kc-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ----------------------------------------------------------------
   Header Section (Logo)
   ---------------------------------------------------------------- */
.cyberframe-login-header {
  text-align: center;
  margin-bottom: 1rem;
}

.cyberframe-logo {
  display: inline-flex;
  margin-bottom: 0.5rem;
  color: hsl(var(--cf-primary));
}

.cyberframe-logo-img {
  height: 80px;
  width: auto;
}

.cyberframe-title {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 2rem 0;
  text-align: center;
}

.cyberframe-title-primary {
  display: block;
  background: linear-gradient(135deg, hsl(var(--cf-primary)), hsl(var(--cf-primary) / 0.8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.025em;
  text-align: center;
}

.cyberframe-title-secondary {
  display: block;
  font-size: 1.125rem;
  font-weight: 400;
  color: hsl(var(--cf-muted-foreground));
  margin-top: 0.25rem;
}

.cyberframe-subtitle {
  color: hsl(var(--cf-muted-foreground));
  font-size: 0.875rem;
  margin: 0;
}

/* ----------------------------------------------------------------
   Form Styles
   ---------------------------------------------------------------- */
#kc-form {
  margin-top: 1rem;
}

.pf-v5-c-form__group {
  margin-bottom: 1.5rem;
}

.pf-v5-c-form__label {
  color: hsl(var(--cf-foreground));
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  display: block;
}

.pf-v5-c-form__label-required {
  color: hsl(var(--cf-error));
  margin-left: 0.25rem;
}

/* Input Group */
.pf-v5-c-input-group {
  position: relative;
  display: flex !important;
  width: 100%;
}

/* Input Fields */
.pf-v5-c-form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--cf-foreground));
  background-color: hsl(var(--cf-background));
  background-clip: padding-box;
  border: 1px solid hsl(var(--cf-border));
  border-radius: var(--cf-radius);
  transition: all 0.2s ease-in-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.pf-v5-c-form-control:hover {
  border-color: hsl(var(--cf-border) / 0.8);
}

.pf-v5-c-form-control:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: hsl(var(--cf-primary));
  box-shadow: 0 0 0 3px hsl(var(--cf-primary) / 0.1);
}

.pf-v5-c-form-control::placeholder {
  color: hsl(var(--cf-muted-foreground) / 0.7);
}

/* Password input — extra right padding for the toggle icon */
.pf-v5-c-input-group .pf-v5-c-form-control {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 3rem;
  border-radius: var(--cf-radius) !important;
}

/* Password visibility toggle — absolutely positioned inside input */
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: auto !important;
  padding: 0.375rem;
  background: transparent !important;
  border: none !important;
  border-radius: var(--cf-radius);
  color: hsl(var(--cf-muted-foreground)) !important;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.pf-v5-c-input-group .pf-v5-c-button.pf-m-control:hover:not(:disabled) {
  background: hsl(var(--cf-muted)) !important;
  transform: translateY(-50%) !important;
  box-shadow: none !important;
}

.pf-v5-c-input-group .pf-v5-c-button.pf-m-control:focus,
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control:active,
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control::before,
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control::after {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

/* Eye icon via CSS (PF5 icon classes are undefined in our theme) */
.pf-v5-c-input-group .pf-v5-c-button.pf-m-control i {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.125em;
  height: 1.125em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
}

/* Error Messages */
.pf-v5-c-helper-text__item--error {
  color: hsl(var(--cf-error));
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.cyberframe-input-error {
  display: block;
  color: hsl(var(--cf-error));
  font-size: 0.8125rem;
  margin-top: 0.375rem;
  font-weight: 500;
}

/* ----------------------------------------------------------------
   Remember Me & Forgot Password
   ---------------------------------------------------------------- */
.pf-v5-c-form__group.pf-v5-c-form__group--action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.checkbox label {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  color: hsl(var(--cf-muted-foreground));
  cursor: pointer;
}

.checkbox input[type="checkbox"] {
  margin-right: 0.5rem;
  cursor: pointer;
}

#kc-form-options a {
  color: hsl(var(--cf-primary));
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s ease-in-out;
}

#kc-form-options a:hover {
  color: hsl(var(--cf-primary) / 0.8);
  text-decoration: underline;
}

/* ----------------------------------------------------------------
   Submit Button
   ---------------------------------------------------------------- */
.pf-v5-c-button {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: hsl(var(--cf-primary-foreground));
  background-color: hsl(var(--cf-primary));
  border: 1px solid transparent;
  border-radius: var(--cf-radius);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  text-transform: none;
  letter-spacing: normal;
  position: relative;
  overflow: hidden;
}

/* Full-width only for block/submit buttons */
.pf-v5-c-button.pf-m-block,
.pf-v5-c-button.pf-m-primary,
#kc-form-buttons .pf-v5-c-button {
  width: 100%;
}

/* Primary button specific */
.pf-v5-c-button.pf-v5-c-button--primary,
#kc-login {
  background-color: hsl(var(--cf-primary)) !important;
  color: hsl(var(--cf-primary-foreground)) !important;
  border-color: hsl(var(--cf-primary)) !important;
}

.pf-v5-c-button:hover:not(:disabled),
.pf-v5-c-button.pf-v5-c-button--primary:hover:not(:disabled),
#kc-login:hover:not(:disabled) {
  background-color: hsl(var(--cf-primary) / 0.9) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px hsl(var(--cf-shadow));
}

.pf-v5-c-button:active:not(:disabled),
.pf-v5-c-button.pf-v5-c-button--primary:active:not(:disabled),
#kc-login:active:not(:disabled) {
  background-color: hsl(var(--cf-primary) / 0.8) !important;
  transform: translateY(0);
  box-shadow: 0 2px 4px -1px hsl(var(--cf-shadow));
}

.pf-v5-c-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----------------------------------------------------------------
   Social Login Section
   ---------------------------------------------------------------- */
#kc-social-providers {
  margin-top: 1.5rem;
  padding-top: 0;
}

#kc-social-providers ul.pf-v5-c-login__main-body {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

#kc-social-providers ul li {
  margin-bottom: 0.5rem;
}

#kc-social-providers ul li:last-child {
  margin-bottom: 0;
}

#kc-social-providers h2 {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--cf-muted-foreground));
  text-align: center;
  margin-bottom: 0.75rem;
}

.pf-v5-c-login__main-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* SSO / Social login buttons */
#kc-social-providers a.pf-v5-c-button,
.pf-v5-c-login__main-footer-links-item-link {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0.75rem 1.5rem !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: hsl(var(--cf-primary)) !important;
  background: hsl(var(--cf-primary) / 0.04) !important;
  border: 1.5px solid hsl(var(--cf-primary) / 0.35) !important;
  border-radius: var(--cf-radius) !important;
  text-decoration: none !important;
  transition: all 0.25s ease !important;
  transform: none !important;
  box-shadow: 0 1px 3px 0 hsl(var(--cf-primary) / 0.06) !important;
}

#kc-social-providers a.pf-v5-c-button:hover,
.pf-v5-c-login__main-footer-links-item-link:hover {
  background: hsl(var(--cf-primary) / 0.08) !important;
  border-color: hsl(var(--cf-primary) / 0.6) !important;
  color: hsl(var(--cf-primary)) !important;
  transform: none !important;
  box-shadow: 0 2px 8px 0 hsl(var(--cf-primary) / 0.12) !important;
}

#kc-social-providers a.pf-v5-c-button:active,
.pf-v5-c-login__main-footer-links-item-link:active {
  background: hsl(var(--cf-primary) / 0.12) !important;
  border-color: hsl(var(--cf-primary) / 0.7) !important;
  box-shadow: none !important;
}

/* Remove PF5 ::after pseudo-element border on social buttons */
#kc-social-providers a.pf-v5-c-button::after,
.pf-v5-c-login__main-footer-links-item-link::after {
  border: none !important;
}

/* ----------------------------------------------------------------
   Registration Link
   ---------------------------------------------------------------- */
#kc-registration-container {
  text-align: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid hsl(var(--cf-border));
}

#kc-registration {
  font-size: 0.875rem;
  color: hsl(var(--cf-muted-foreground));
}

#kc-registration a {
  color: hsl(var(--cf-primary));
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease-in-out;
}

#kc-registration a:hover {
  color: hsl(var(--cf-primary) / 0.8);
  text-decoration: underline;
}

/* ----------------------------------------------------------------
   Alert Messages
   ---------------------------------------------------------------- */
.pf-v5-c-alert {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border-radius: var(--cf-radius);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.pf-v5-c-alert--success {
  background-color: hsl(var(--cf-success) / 0.1);
  border: 1px solid hsl(var(--cf-success) / 0.2);
  color: hsl(var(--cf-success));
}

.pf-v5-c-alert--danger {
  background-color: hsl(var(--cf-error) / 0.1);
  border: 1px solid hsl(var(--cf-error) / 0.2);
  color: hsl(var(--cf-error));
}

.pf-v5-c-alert--warning {
  background-color: hsl(var(--cf-warning) / 0.1);
  border: 1px solid hsl(var(--cf-warning) / 0.2);
  color: hsl(var(--cf-warning));
}

.pf-v5-c-alert--info {
  background-color: hsl(var(--cf-info) / 0.1);
  border: 1px solid hsl(var(--cf-info) / 0.2);
  color: hsl(var(--cf-info));
}

/* ----------------------------------------------------------------
   Loading State
   ---------------------------------------------------------------- */
.pf-v5-c-button--loading {
  color: transparent;
}

.pf-v5-c-button--loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid hsl(var(--cf-primary-foreground));
  border-radius: 50%;
  border-top-color: transparent;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------
   Logout Confirmation
   ---------------------------------------------------------------- */
.cyberframe-logout-confirm {
  text-align: center;
}

.cyberframe-logout-message {
  font-size: 1.125rem;
  color: hsl(var(--cf-foreground));
  margin-bottom: 2rem;
  line-height: 1.6;
}

.cyberframe-logout-info {
  background: hsl(var(--cf-muted));
  border-radius: var(--cf-radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.cyberframe-info-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  text-align: left;
  font-size: 0.875rem;
  color: hsl(var(--cf-muted-foreground));
}

.cyberframe-info-item:last-child {
  margin-bottom: 0;
}

.cyberframe-info-icon {
  flex-shrink: 0;
  color: hsl(var(--cf-primary));
}

.cyberframe-button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cyberframe-button-secondary {
  background: hsl(var(--cf-background)) !important;
  color: hsl(var(--cf-foreground)) !important;
  border: 1px solid hsl(var(--cf-border)) !important;
}

.cyberframe-button-secondary:hover {
  background: hsl(var(--cf-muted)) !important;
  border-color: hsl(var(--cf-primary) / 0.3) !important;
}

#kc-logout {
  background-color: hsl(var(--cf-primary)) !important;
  color: hsl(var(--cf-primary-foreground)) !important;
  border-color: hsl(var(--cf-primary)) !important;
}

#kc-logout:hover:not(:disabled) {
  background-color: hsl(var(--cf-primary) / 0.9) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px hsl(var(--cf-shadow));
}

#kc-logout:active:not(:disabled) {
  background-color: hsl(var(--cf-primary) / 0.8) !important;
  transform: translateY(0);
  box-shadow: 0 2px 4px -1px hsl(var(--cf-shadow));
}

/* ----------------------------------------------------------------
   Error Page
   ---------------------------------------------------------------- */
.cyberframe-logo--error {
  color: hsl(var(--cf-error));
}

.cyberframe-title--error {
  color: hsl(var(--cf-error));
}

.cyberframe-error-container {
  text-align: left;
}

.cyberframe-error-details {
  margin: 1rem 0 0.5rem 0;
  font-size: 0.875rem;
}

.cyberframe-error-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.cyberframe-error-list li {
  padding: 0.25rem 0;
  font-size: 0.875rem;
}

.cyberframe-error-list code {
  background: hsl(var(--cf-muted));
  padding: 0.125rem 0.375rem;
  border-radius: calc(var(--cf-radius) * 0.5);
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.8125rem;
}

.cyberframe-error-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 2rem 0;
}

.cyberframe-error-help {
  background: hsl(var(--cf-muted));
  border-radius: var(--cf-radius);
  padding: 1.5rem;
  margin-top: 2rem;
}

.cyberframe-error-help h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: hsl(var(--cf-foreground));
}

.cyberframe-error-help p {
  font-size: 0.875rem;
  color: hsl(var(--cf-muted-foreground));
  margin: 0 0 0.5rem 0;
}

.cyberframe-error-help ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0;
}

.cyberframe-error-help li {
  font-size: 0.875rem;
  color: hsl(var(--cf-muted-foreground));
  padding: 0.125rem 0;
}

/* ----------------------------------------------------------------
   Registration Notice
   ---------------------------------------------------------------- */
.cyberframe-register-notice {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: hsl(var(--cf-muted-foreground));
  text-align: center;
}

/* ----------------------------------------------------------------
   Footer
   ---------------------------------------------------------------- */
.cyberframe-footer {
  margin-top: 2rem;
  padding-bottom: 2rem;
  text-align: center;
}

.cyberframe-footer-content {
  font-size: 0.75rem;
  color: hsl(var(--cf-muted-foreground));
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 640px) {
  #kc-content {
    padding: 2rem 1.5rem;
    margin: 0 1rem;
  }

  .cyberframe-title {
    font-size: 1.5rem;
  }

  .cyberframe-title-secondary {
    font-size: 1rem;
  }
}

/* ----------------------------------------------------------------
   Accessibility
   ---------------------------------------------------------------- */
*:focus-visible {
  outline: 2px solid hsl(var(--cf-primary));
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ----------------------------------------------------------------
   Print
   ---------------------------------------------------------------- */
@media print {
  #kc-content {
    box-shadow: none;
    border: 1px solid #000;
  }
}
