/* ═══════════════════════════════════════════════════════════════════
   Alpamayo Intelligence — Keycloak login theme
   Design: single centered column, Microsoft-first, Poppins,
   orange only as brand hairline + logomark. Light + dark.
   Tokens: alpamayo-design/assets/css/tokens.css
   ═══════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Alpamayo palette */
  --primary-300: #82b0bf;
  --primary-400: #3f7791;
  --primary-500: #134562;
  --primary-700: #0a2c47;
  --primary-900: #04162b;
  --primary-950: #020d1c;
  --secondary-500: #f55632;
  --secondary-600: #e4340a;
  --surface-0: #ffffff;
  --surface-50: #f9fbff;
  --surface-200: #e9ecf7;
  --surface-300: #d0d4e2;
  --surface-500: #7b809a;
  --surface-800: #343646;
  --danger-50: #fef2f2;
  --danger-300: #fca5a5;
  --danger-500: #ef4444;
  --danger-700: #b91c1c;
  --radius: 6px;

  /* semantic (light) */
  --bg: var(--surface-50);
  --fg: var(--surface-800);
  --muted: var(--surface-500);
  --card: var(--surface-0);
  --card-shadow: 0px 1px 2px 0px rgba(164, 172, 185, 0.24),
    0px 0px 0px 1px rgba(18, 55, 105, 0.08);
  --field-border: var(--surface-300);
  --divider: var(--surface-200);
  --link: var(--primary-400);
  --idp-btn-bg: var(--primary-500);
  --idp-btn-fg: #ffffff;
  --idp-btn-hover: var(--primary-700);
  --logo-url: url("../img/logo-standard.svg");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--primary-950);
    --fg: #e8edf2;
    --muted: #8fa0b0;
    --card: rgba(255, 255, 255, 0.035);
    --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    --field-border: rgba(255, 255, 255, 0.16);
    --divider: rgba(255, 255, 255, 0.1);
    --link: var(--primary-300);
    --idp-btn-bg: #ffffff;
    --idp-btn-fg: var(--primary-900);
    --idp-btn-hover: #dfe7ee;
    --logo-url: url("../img/logo-inverted.svg");
    color-scheme: dark;
  }
}

/* ── Page ──────────────────────────────────────────────────────── */

.login-pf body {
  background: var(--bg) !important;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  color: var(--fg);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* brand hairline — the only orange besides the logomark */
.login-pf body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--secondary-500);
  z-index: 5;
}

.login-pf-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 16px;
}

/* ── Logo ──────────────────────────────────────────────────────── */

#kc-header-wrapper {
  display: flex;
  justify-content: center;
  padding: 0;
}

div.kc-logo-text {
  background-image: var(--logo-url);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  height: 53px;
  width: 168px;
  margin: 0 auto;
}

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

.login-pf-page .login-pf-header {
  margin-bottom: 24px !important;
}

/* page title stays for a11y / tab title, visually hidden */
#kc-page-title {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#kc-locale {
  display: none;
}

/* ── Card ──────────────────────────────────────────────────────── */

.card-pf {
  width: 384px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 28px 32px;
  margin-bottom: 0;
}

/* order: alerts → IdP button → divider+form (template renders form first) */
#kc-content-wrapper {
  display: flex;
  flex-direction: column;
}
#kc-content-wrapper .alert {
  order: -2;
}
#kc-social-providers {
  order: -1;
}

/* ── Identity provider (Microsoft) — the primary path ─────────── */

#kc-social-providers ul.alp-idp-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#kc-social-providers li + li {
  margin-top: 10px;
}

a.alp-btn-idp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 46px;
  border-radius: var(--radius);
  background: var(--idp-btn-bg);
  color: var(--idp-btn-fg) !important;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none !important;
  transition: background 0.15s, transform 0.05s;
}
a.alp-btn-idp:hover,
a.alp-btn-idp:focus {
  background: var(--idp-btn-hover);
  color: var(--idp-btn-fg) !important;
}
a.alp-btn-idp:active {
  transform: translateY(1px);
}

/* monochrome 4-tile mark, follows button text color (Microsoft only) */
.alp-idp-icon {
  display: none;
}
#social-microsoft .alp-idp-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 21 21'%3E%3Crect x='1' y='1' width='9' height='9'/%3E%3Crect x='11' y='1' width='9' height='9'/%3E%3Crect x='1' y='11' width='9' height='9'/%3E%3Crect x='11' y='11' width='9' height='9'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 21 21'%3E%3Crect x='1' y='1' width='9' height='9'/%3E%3Crect x='11' y='1' width='9' height='9'/%3E%3Crect x='1' y='11' width='9' height='9'/%3E%3Crect x='11' y='11' width='9' height='9'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* ── Divider ───────────────────────────────────────────────────── */

.alp-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  color: var(--muted);
  font-size: 12px;
}
.alp-divider::before,
.alp-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

/* ── Form ──────────────────────────────────────────────────────── */

#kc-form label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 6px;
}

.pf-c-form-control {
  width: 100% !important;
  height: 40px !important;
  padding: 0 12px !important;
  box-sizing: border-box;
  font-family: inherit !important;
  font-size: 14px !important;
  color: var(--fg) !important;
  background: transparent !important;
  border: 1px solid var(--field-border) !important;
  border-radius: var(--radius) !important;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pf-c-form-control:focus {
  border-color: var(--primary-400) !important;
  box-shadow: 0 0 0 3px rgba(63, 119, 145, 0.16);
}
.pf-c-form-control[aria-invalid="true"] {
  border-color: var(--danger-500) !important;
}

/* password input group: field + visibility toggle */
.pf-c-input-group {
  display: flex;
}
.pf-c-input-group .pf-c-form-control {
  flex: 1;
  border-radius: var(--radius) 0 0 var(--radius) !important;
}
.pf-c-input-group .pf-c-button {
  width: 42px;
  border: 1px solid var(--field-border) !important;
  border-left: 0 !important;
  border-radius: 0 var(--radius) var(--radius) 0 !important;
  background: transparent !important;
  color: var(--muted) !important;
  cursor: pointer;
}
.pf-c-input-group .pf-c-button:hover {
  color: var(--fg) !important;
}
.pf-c-button::after {
  border: none !important;
}

#input-error {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger-500) !important;
}

/* options row: remember-me / forgot password */
.login-pf-settings {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0 16px !important;
  font-size: 12.5px;
}
#kc-form a {
  color: var(--link);
  font-size: 12.5px;
  text-decoration: none;
}
#kc-form a:hover {
  text-decoration: underline;
}
.checkbox {
  margin: 0;
  color: var(--muted);
}

/* submit — visibly secondary to the IdP button */
#kc-form-buttons {
  margin-top: 0;
}
.pf-c-button.pf-m-primary {
  width: 100%;
  height: 40px;
  background: transparent !important;
  color: var(--fg) !important;
  border: 1px solid var(--field-border) !important;
  border-radius: var(--radius) !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.pf-c-button.pf-m-primary:hover {
  background: rgba(63, 119, 145, 0.08) !important;
}
.pf-c-button.pf-m-primary:active {
  transform: translateY(1px);
}

/* ── Collapsed email form ──────────────────────────────────────── */
/* Secondary path, folded behind a native <details> disclosure. The
   template forces it open on a failed login and when no IdP exists. */

.alp-email {
  margin-top: 14px;
}

summary.alp-email-toggle {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  transition: background 0.15s;
}
summary.alp-email-toggle::-webkit-details-marker {
  display: none;
}
summary.alp-email-toggle:hover {
  background: rgba(63, 119, 145, 0.08);
}
summary.alp-email-toggle:focus-visible {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
}

/* Chevron drawn in CSS so no icon font or inline SVG is needed. */
.alp-chev {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--muted);
  transition: transform 0.2s;
}
.alp-email[open] summary.alp-email-toggle {
  border-color: transparent;
  background: transparent;
  margin-bottom: 4px;
}
.alp-email[open] .alp-chev {
  transform: rotate(90deg);
}

.alp-email-panel {
  padding-top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .alp-chev,
  summary.alp-email-toggle {
    transition: none;
  }
}

/* ── Help line + alerts ────────────────────────────────────────── */

.alp-help {
  margin-top: 22px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}

.alert {
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error {
  background: var(--danger-50);
  color: var(--danger-700);
  border: 1px solid var(--danger-300);
}
@media (prefers-color-scheme: dark) {
  .alert-error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger-300);
    border: 1px solid rgba(239, 68, 68, 0.35);
  }
}
.pf-c-alert__icon {
  display: none;
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 440px) {
  .card-pf {
    width: 100%;
    padding: 24px 20px;
  }
}
