/* Account portal (assets/auth-portal.js): one centred card — logo, tabs, providers, email form.
   Values from assets/tokens.css («ليل الرياض»: navy for actions, saffron only to accent). */
.session-card.auth-portal-card {
  width: min(100%, 520px);
  padding: clamp(22px, 5vw, 40px);
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 28px;
  background: var(--surface, #ffffff);
  box-shadow: 0 24px 80px rgba(22, 50, 92, 0.12);
  text-align: start;
}
.auth-portal {
  --auth-error: var(--danger, #a32929);
  --auth-error-bg: var(--danger-soft, #fff2f2);
  --auth-success: var(--success, #166348);
  --auth-success-bg: var(--success-soft, #eef9f3);
  display: grid;
  gap: 20px;
  color: var(--text, #222b38);
  font-family: var(--font);
  font-size: var(--fs-base, 15px);
  line-height: 1.7;
}
.auth-portal *,
.auth-portal *::before,
.auth-portal *::after {
  box-sizing: border-box;
}
.auth-portal [hidden] {
  display: none !important;
}
.auth-portal button,
.auth-portal input {
  font: inherit;
}
.auth-portal button {
  cursor: pointer;
}
.auth-portal button:disabled {
  cursor: not-allowed;
}
.auth-portal a {
  text-decoration: none;
}
.auth-portal p {
  margin: 0;
}
.auth-portal :is(a, button, input):focus-visible {
  outline: 3px solid var(--accent-line, #f2a33a);
  outline-offset: 2px;
}
.auth-portal h1:focus {
  outline: none;
}

/* Top: close · logo · balance */
.auth-top {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
}
.auth-close {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 14px;
  color: var(--text, #222b38);
}
.auth-close:hover {
  background: var(--surface-2, #f5f7fa);
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 10px;
  color: var(--navy, #16325c);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.auth-logo img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

/* Tabs */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: var(--surface-2, #f1f4f8);
}
.auth-tab {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 12px;
  color: var(--muted, #6b7585);
  font-weight: 600;
}
.auth-tab[aria-selected='true'] {
  background: var(--surface, #ffffff);
  color: var(--text, #222b38);
  box-shadow: 0 2px 8px rgba(22, 50, 92, 0.08);
}

/* Heading */
.session-card.auth-portal-card .auth-header h1 {
  margin: 0 0 6px;
  color: var(--text, #222b38);
  font-size: clamp(24px, 4vw, 30px);
  font-weight: 700;
  line-height: 1.4;
}
.session-card.auth-portal-card .auth-header p,
.auth-context {
  color: var(--muted, #6b7585);
  font-size: var(--fs-sm, 14px);
  line-height: 1.8;
}

/* Notes and status */
.auth-status,
.auth-closure,
.auth-capability-note,
.auth-email-note,
.auth-token-note {
  padding: 12px 14px;
  border: 1px solid var(--border, #e6eaf0);
  border-radius: 14px;
  background: var(--surface-2, #f5f7fa);
  color: var(--text-2, #3c4656);
  font-size: var(--fs-sm, 14px);
}
.auth-capability-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.auth-status[data-kind='error'],
.auth-token-note {
  border-color: #efcaca;
  background: var(--auth-error-bg);
  color: var(--auth-error);
}
.auth-status[data-kind='success'] {
  border-color: #c5e8d6;
  background: var(--auth-success-bg);
  color: var(--auth-success);
}
.auth-inline-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--navy, #16325c);
  font-weight: 700;
  text-decoration: underline;
}

/* Providers, side by side */
.auth-providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
}
.auth-provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong, #d5dce6);
  border-radius: 16px;
  background: var(--surface, #ffffff);
  color: var(--text, #222b38);
  font-weight: 700;
}
.auth-provider:hover:not(:disabled) {
  border-color: var(--navy, #16325c);
}
.auth-provider img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.auth-provider small {
  color: var(--muted, #6b7585);
  font-weight: 400;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted, #6b7585);
  font-size: var(--fs-sm, 14px);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, #e6eaf0);
}

/* Form */
.auth-form {
  display: grid;
  gap: 16px;
}
.auth-field {
  display: grid;
  gap: 8px;
}
.auth-field label {
  font-weight: 700;
}
.auth-input-wrap {
  position: relative;
}
.auth-input-wrap input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong, #d5dce6);
  border-radius: 14px;
  background: var(--surface-2, #f8fafc);
  color: var(--text, #222b38);
}
.auth-input-wrap input:focus {
  border-color: var(--navy, #16325c);
  background: var(--surface, #ffffff);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft, #e7edf6);
}
.auth-input-wrap input[aria-invalid='true'] {
  border-color: var(--auth-error);
}
.auth-password-wrap input {
  /* The field is left-to-right inside a right-to-left page: the eye sits on the left. */
  padding-left: 52px;
}
.auth-password-toggle {
  position: absolute;
  inset-block: 0;
  left: 6px;
  display: grid;
  place-items: center;
  width: 44px;
  border: 0;
  background: none;
  color: var(--muted, #6b7585);
}
.auth-password-toggle .auth-eye-off,
.auth-password-toggle[aria-pressed='true'] .auth-eye {
  display: none;
}
.auth-password-toggle[aria-pressed='true'] .auth-eye-off {
  display: block;
}
.auth-hint {
  color: var(--muted, #6b7585);
  font-size: var(--fs-xs, 12px);
}
.auth-field-error {
  color: var(--auth-error);
  font-size: var(--fs-xs, 12px);
}
.auth-form-tools {
  margin-top: -4px;
}
.auth-text-link {
  color: var(--navy, #16325c);
  font-size: var(--fs-sm, 14px);
  font-weight: 600;
}
.auth-text-link:hover {
  text-decoration: underline;
}
.auth-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 20px;
  border: 0;
  border-radius: 16px;
  background: var(--accent-action, #16325c);
  color: var(--on-brand, #ffffff);
  font-weight: 700;
  font-size: var(--fs-md, 16px);
}
.auth-submit:hover:not(:disabled) {
  background: var(--accent-action-hover, #0f2444);
}
.auth-submit:disabled {
  opacity: 0.55;
}
.auth-submit[aria-busy='true'] .auth-submit-arrow,
.auth-portal[data-busy='true'] .auth-submit-arrow {
  display: none;
}
.auth-spinner {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid #ffffff60;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: auth-spin 0.75s linear infinite;
}
@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}
.auth-view-links {
  text-align: center;
  color: var(--muted, #6b7585);
  font-size: var(--fs-sm, 14px);
}
.auth-safe-entry {
  display: grid;
  gap: 8px;
}
.auth-safe-button {
  min-height: 52px;
  border: 1px solid var(--border-strong, #d5dce6);
  border-radius: 16px;
  background: var(--surface, #ffffff);
  font-weight: 700;
}
.auth-safe-entry p {
  color: var(--muted, #6b7585);
  font-size: var(--fs-xs, 12px);
}

/* Dark mode */
body.dark .auth-close,
body.dark .auth-provider,
body.dark .auth-input-wrap input {
  border-color: var(--border-strong, #3a4658);
}
body.dark .auth-logo,
body.dark .auth-text-link {
  color: var(--text, #e7ecf3);
}

@media (max-width: 520px) {
  .session-card.auth-portal-card {
    border-radius: 22px;
  }
  .auth-portal {
    gap: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .auth-spinner {
    animation-duration: 2s;
  }
}
