/* ─── Reset & Base (from global.scss) ─── */
:root {
  --color-accent: #0b483b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
*:focus-visible {
  outline: none;
}

html {
  color: #424142;
  height: 100%;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  height: 100%;
  background-image: url("https://cdn.alpha.co.za/treaty-portal/home-page.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ─── Page layout: flex justify-center items-center h-full w-full relative ─── */
.page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  position: relative;
}

/* ─── Gradient overlay: absolute inset-0 ─── */
.overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0) 55%);
  pointer-events: none;
}

/* ─── Panel (just a pass-through, card does the work) ─── */
.panel {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 1rem;
}

/* ─── Card: bg-opacity-85 bg-white border border-gray-400 border-2
          drop-shadow-[0_0_5px_rgba(255,255,255,0.7)] rounded-3xl p-6 max-w-sm w-full relative ─── */
.card {
  background-color: rgba(255, 255, 255, 0.85);
  border: 2px solid #9ca3af;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
  border-radius: 1.5rem;
  padding: 1.5rem;
  max-width: 24rem;
  width: 100%;
  position: relative;
}

/* ─── Logo: flex justify-center items-center w-full mb-4
          inner: h-[80px] w-full bg-center bg-contain bg-no-repeat ─── */
.logo-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 1rem;
}

.logo-wrap img {
  height: 100px;
  width: 100%;
  object-fit: contain;
  object-position: center;
}

/* ─── Title: text-center mb-6 → h1: text-xl font-bold ─── */
h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 700;
}

.muted {
  display: none;
}

/* ─── Form: mb-6 px-8 ─── */
.form {
  margin-bottom: 1.5rem;
  padding: 0 2rem;
}

/* ─── Auth method toggles ─── */
.auth-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.method-option {
  border: 1px solid #9ca3af;
  background: rgba(255, 255, 255, 0.6);
  color: #424142;
  border-radius: 0.625rem;
  padding: 0.5rem 0.625rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

.method-option:hover {
  background: rgba(255, 255, 255, 0.9);
}

.method-option.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ─── Credentials fields: grid grid-flow-row gap-4 ─── */
#credentials-fields {
  display: grid;
  grid-auto-flow: row;
  gap: 1rem;
}

/* ─── Field + field_control_underline ─── */
.field {
  position: relative;
}

.field label {
  display: none;
}

/* The underline container: border-bottom 2px solid #fff, focus-within → #0B483B */
.field-underline {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 2px solid #fff;
  transition: border-color 0.2s;
}

.field-underline:focus-within {
  border-bottom-color: var(--color-accent);
}

/* Fallback: if no .field-underline wrapper, style .field itself as underline */
.field:not(:has(.field-underline)) {
  display: flex;
  align-items: center;
  border-bottom: 2px solid #fff;
  transition: border-color 0.2s;
}

.field:not(:has(.field-underline)):focus-within {
  border-bottom-color: var(--color-accent);
}

/* ─── Field icon: .field_icon / .field-icon ─── */
.field-icon {
  color: #6f6e70;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  min-height: 1.5rem;
  margin-left: 0.25rem;
  z-index: 2;
  flex-shrink: 0;
}

.field-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* ─── Input (inside field_control_underline) ─── */
.fake-input {
  background: transparent;
  width: 100%;
  padding: 0.25rem 0.75rem;
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-size: 0.95rem;
  color: #535255;
  font-family: inherit;
  transition: border-color 0.2s;
  position: relative;
  z-index: 1;
  outline: none;
  min-height: 2.25rem;
}

.fake-input:focus {
  outline: none;
  box-shadow: none;
}

.fake-input::placeholder {
  color: #6f6e70;
  opacity: 1;
}

/* ─── Password control (wraps input + toggle) ─── */
.password-control {
  position: relative;
  width: 100%;
  flex: 1;
  min-width: 0;
}

.password-control .fake-input {
  padding-right: 2.5rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.25rem;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: #6f6e70;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}

.password-toggle:hover {
  color: var(--color-accent);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* ─── Forgot Password: text-right text-[var(--color-accent)] text-sm cursor-pointer mt-2 ─── */
.helper {
  text-align: right;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0;
}

.helper:has(> .hidden:only-child),
.helper:empty {
  margin: 0;
  padding: 0;
  height: 0;
}

.helper a {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
}

.helper a:hover {
  text-decoration: underline;
}

/* "Back to sign in" — centered */
.helper:last-of-type {
  text-align: center;
  margin-top: 0.75rem;
}

/* ─── Primary button: px-8 wrapper, then
       bg-[var(--color-accent)] text-white rounded-full p-3 text-md font-bold w-full ─── */
button.primary,
a.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 4rem);
  margin: 0 2rem;
  padding: 0.75rem;
  border-radius: 9999px;
  border: none;
  background: var(--color-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.15s;
}

button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary:hover:not(:disabled),
a.primary:hover {
  opacity: 0.9;
}

/* ─── Hidden ─── */
.hidden {
  display: none !important;
}

/* ─── Error / Message ─── */
.message {
  min-height: 0;
  margin: 0;
  padding: 0 2rem;
  color: #ef4444;
  font-size: 0.875rem;
  text-align: center;
}

.message:not(:empty) {
  margin: 0.5rem 0;
}

/* ─── Alt actions ─── */
.alt-actions {
  margin-top: 0.625rem;
  padding: 0 2rem;
  display: grid;
  gap: 0.5rem;
}

.action-wide {
  width: 100%;
  justify-content: center;
}

.passkey-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #6f6e70;
  text-align: center;
  line-height: 1.35;
}

#auth-method-help {
  margin-bottom: 0.5rem;
  padding: 0;
}

/* ─── Ghost buttons ─── */
.ghost {
  border: 1px solid #9ca3af;
  background: rgba(255, 255, 255, 0.5);
  color: #424142;
  border-radius: 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.ghost:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ─── Setup panels (MFA / Passkey) ─── */
.setup {
  margin: 0.625rem 0 0.75rem 0;
  display: grid;
  gap: 0.625rem;
}

.setup-title {
  margin: 0;
  font-weight: 600;
  color: #424142;
}

.setup-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 0.625rem;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid #9ca3af;
  overflow: hidden;
}

.setup-qr {
  width: 180px;
  height: 180px;
  margin: 0 auto;
  display: block;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.5rem;
}

.setup-secret {
  font-family: "SFMono-Regular", ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: #424142;
  word-break: break-all;
  overflow-wrap: break-word;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

.setup-help {
  margin: 0;
  font-size: 0.85rem;
  color: #6f6e70;
}

.signup-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #6f6e70;
}

#resend-code,
#forgot-resend-code {
  margin-top: 0.375rem;
  align-self: flex-start;
}

/* ─── Button label + inline spinner ─── */
.button-label {
  display: inline;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  opacity: 0;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.25rem;
}

button.primary.loading .spinner {
  opacity: 1;
}

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

/* ─── Expired panel ─── */
#expired-panel {
  text-align: center;
  padding: 0.75rem 2rem;
}

/* ─── Footer ─── */
.footer {
  margin-top: 1rem;
  text-align: center;
  padding: 0 2rem;
}

.footer a {
  color: #6f6e70;
  text-decoration: none;
  font-size: 0.875rem;
}

.footer a:hover {
  color: var(--color-accent);
}

.divider {
  margin: 0 0.5rem;
  color: rgba(0, 0, 0, 0.35);
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .overlay {
    background: rgba(0, 0, 0, 0.3);
  }
  .card {
    max-width: 95%;
    padding: 1.25rem;
  }
  .form {
    padding: 0 1rem;
  }
  button.primary,
  a.primary {
    width: calc(100% - 2rem);
    margin: 0 1rem;
  }
  .alt-actions {
    padding: 0 1rem;
  }
}
