/* Sign-in, password and reset pages. Mirrors the mobile app's LoginScreen (Mobile_App/src/screens/auth). */
:root {
  --auth-primary: #0b4f8a;
  --auth-primary-dark: #083a66;
  --auth-accent: #1d6fbf;
  --auth-bg: #f3f5f8;
  --auth-surface: #ffffff;
  --auth-text: #122033;
  --auth-muted: #667085;
  --auth-border: #d0d5dd;
  --auth-danger: #b42318;
  --auth-danger-bg: #fef3f2;
  --auth-success-bg: #ecfdf3;
  --auth-warning-bg: #fffaeb;
  --auth-info-bg: #e8f1fb;
  --auth-shadow: 0 8px 20px rgba(11, 18, 32, 0.12);
}

html,
body.kswan-auth {
  min-height: 100%;
}

body.kswan-auth *,
body.kswan-auth *::before,
body.kswan-auth *::after {
  box-sizing: border-box;
}

body.kswan-auth input,
body.kswan-auth button {
  font-family: inherit;
}

body.kswan-auth {
  margin: 0;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Hero ---- */
.auth-hero {
  position: relative;
  overflow: hidden;
  background: var(--auth-primary);
  color: #fff;
  text-align: center;
  padding: 48px 24px 112px;
  border-bottom-left-radius: 36px;
  border-bottom-right-radius: 36px;
}

.auth-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.auth-glow-lg {
  width: 360px;
  height: 360px;
  top: -130px;
  right: -110px;
  background: var(--auth-accent);
  opacity: 0.35;
}

.auth-glow-sm {
  width: 220px;
  height: 220px;
  bottom: -60px;
  left: -70px;
  background: var(--auth-primary-dark);
  opacity: 0.5;
}

.auth-emblem-ring {
  position: relative;
  width: 116px;
  height: 116px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.35);
  background-clip: padding-box;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--auth-shadow);
}

.auth-emblem-ring img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}

.auth-title {
  position: relative;
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.auth-subtitle {
  position: relative;
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.auth-pill {
  position: relative;
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

/* ---- Card ---- */
.auth-card {
  position: relative;
  width: calc(100% - 32px);
  max-width: 460px;
  margin: -64px auto 0;
  background: var(--auth-surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--auth-shadow);
}

.auth-card.auth-card-wide {
  max-width: 560px;
}

.auth-card-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--auth-text);
}

.auth-card-subtitle {
  margin: 4px 0 24px;
  color: var(--auth-muted);
  font-size: 14px;
}

/* ---- Fields (match TextField) ---- */
.auth-field {
  margin-bottom: 16px;
}

.auth-label {
  display: block;
  margin-bottom: 6px;
  color: var(--auth-text);
  font-weight: 600;
  font-size: 14px;
}

.auth-input-wrap {
  position: relative;
}

.auth-input {
  display: block;
  width: 100%;
  border: 1px solid var(--auth-border);
  border-radius: 8px;
  background: var(--auth-surface);
  padding: 12px 10px;
  color: var(--auth-text);
  font-size: 16px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-input::placeholder {
  color: var(--auth-muted);
}

.auth-input:focus {
  outline: none;
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px rgba(11, 79, 138, 0.15);
}

.auth-input[readonly] {
  background: #e4e7ec;
  color: var(--auth-muted);
}

.auth-input.input-validation-error {
  border-color: var(--auth-danger);
}

.auth-input-wrap .auth-input.has-toggle {
  padding-right: 64px;
}

.auth-toggle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 10px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--auth-primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.auth-error,
.auth-field .field-validation-error {
  display: block;
  margin-top: 4px;
  color: var(--auth-danger);
  font-size: 13px;
}

/* ---- Banners (match Banner) ---- */
.auth-banner {
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 16px;
  color: var(--auth-text);
  font-size: 14px;
}

.auth-banner ul {
  margin: 0;
  padding-left: 18px;
}

.auth-banner-danger { background: var(--auth-danger-bg); }
.auth-banner-success { background: var(--auth-success-bg); }
.auth-banner-warning { background: var(--auth-warning-bg); }
.auth-banner-info { background: var(--auth-info-bg); }

.auth-banner.validation-summary-valid {
  display: none;
}

/* ---- Buttons (match AppButton) ---- */
.auth-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  background: var(--auth-primary);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.auth-submit:hover { background: var(--auth-primary-dark); }
.auth-submit:active { transform: scale(0.99); }
.auth-submit:disabled { opacity: 0.7; cursor: default; }

.auth-links {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
}

.auth-links a {
  color: var(--auth-primary);
  font-weight: 700;
  text-decoration: none;
}

.auth-links a:hover { text-decoration: underline; }

.auth-links .sep {
  margin: 0 8px;
  color: var(--auth-border);
}

.auth-note {
  margin: 16px 0 0;
  text-align: center;
  color: var(--auth-muted);
  font-size: 12px;
}

.auth-rules {
  background: var(--auth-bg);
  border: 1px solid var(--auth-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.auth-rules-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-rules ul {
  margin: 0;
  padding-left: 18px;
  color: var(--auth-muted);
  line-height: 1.55;
}

/* ---- Profile page ---- */
.auth-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.auth-avatar {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--auth-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  overflow: hidden;
  position: relative;
}

.auth-avatar-photo {
  width: 72px;
  height: 72px;
  font-size: 24px;
}

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.auth-profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.auth-linkish {
  border: 0;
  background: none;
  color: var(--auth-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.auth-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 16, 28, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-crop-modal[hidden] {
  display: none !important;
}

.auth-crop-dialog {
  width: min(100%, 520px);
  background: var(--auth-surface);
  border-radius: 16px;
  padding: 16px 16px 18px;
  box-shadow: var(--auth-shadow);
}

.auth-crop-stage {
  width: 100%;
  height: min(52vh, 360px);
  background: #111827;
  border-radius: 12px;
  overflow: hidden;
}

.auth-crop-stage img {
  display: block;
  max-width: 100%;
}

.auth-crop-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.auth-crop-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--auth-border);
  background: var(--auth-surface);
  color: var(--auth-text);
  cursor: pointer;
}

.auth-crop-zoom {
  flex: 1;
  min-width: 120px;
}

.auth-crop-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.auth-card-subtitle.auth-tight { margin-bottom: 0; }

.auth-section {
  border-top: 1px solid var(--auth-border);
  padding-top: 16px;
  margin-top: 16px;
}

.auth-section-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.auth-dl {
  display: grid;
  grid-template-columns: minmax(120px, 34%) 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 14px;
}

.auth-dl dt { color: var(--auth-muted); }
.auth-dl dd { margin: 0; word-break: break-word; }

.auth-note.auth-left { text-align: left; margin-top: 10px; }
.auth-muted { color: var(--auth-muted); }

.auth-row {
  display: flex;
  gap: 8px;
}

.auth-row .auth-input { flex: 1 1 auto; min-width: 0; }

.auth-submit.auth-submit-inline {
  width: auto;
  min-height: 0;
  margin-top: 0;
  padding: 0 18px;
  flex: 0 0 auto;
}

.auth-code {
  font-family: Consolas, "Courier New", monospace;
  letter-spacing: 0.3em;
  text-align: center;
}

.auth-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.auth-chip-success { background: var(--auth-success-bg); color: #027a48; }

/* ---- Footer ---- */
.auth-footer {
  margin-top: auto;
  padding: 32px 16px 20px;
  text-align: center;
}

.auth-powered {
  color: var(--auth-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.auth-footer img {
  width: 150px;
  height: 34px;
  object-fit: contain;
}

.auth-copy {
  margin-top: 10px;
  color: var(--auth-muted);
  font-size: 12px;
}

/* ---- Busy overlay (match the sign-in modal) ---- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 32, 51, 0.55);
}

.auth-overlay.show { display: flex; }

.auth-spinner-card {
  width: 100%;
  max-width: 320px;
  background: var(--auth-surface);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
}

.auth-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 4px solid rgba(11, 79, 138, 0.2);
  border-top-color: var(--auth-primary);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

.auth-spinner-title {
  margin-top: 14px;
  font-size: 17px;
  font-weight: 800;
}

.auth-spinner-body {
  margin-top: 6px;
  color: var(--auth-muted);
  line-height: 1.4;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 768px) {
  .auth-hero {
    padding-top: 64px;
    padding-bottom: 128px;
  }

  .auth-emblem-ring {
    width: 132px;
    height: 132px;
  }

  .auth-emblem-ring img {
    width: 114px;
    height: 114px;
  }

  .auth-title { font-size: 34px; }
  .auth-subtitle { font-size: 16px; }

  .auth-card {
    margin-top: -80px;
    padding: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-spinner { animation-duration: 2s; }
}

/* ---- Language toggle (card top-right corner) ---- */
.auth-lang-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--auth-border);
  border-radius: 999px;
  background: var(--auth-bg);
}
.auth-lang-toggle button {
  min-width: 44px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--auth-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-lang-toggle button:hover { color: var(--auth-primary); }
.auth-lang-toggle button.is-active { background: var(--auth-primary); color: #fff; }
.auth-card-title.auth-has-toggle { padding-right: 120px; }

/* ---- Compact sign-in: fits one screen without scrolling ---- */
body.auth-compact .auth-page { height: 100vh; min-height: 0; }
body.auth-compact .auth-hero { padding: 24px 24px 76px; border-bottom-left-radius: 28px; border-bottom-right-radius: 28px; }
body.auth-compact .auth-emblem-ring { width: 100px; height: 100px; margin-bottom: 10px; border-width: 3px; }
body.auth-compact .auth-emblem-ring img { width: 88px; height: 88px; }
body.auth-compact .auth-title { font-size: 26px; }
body.auth-compact .auth-subtitle { font-size: 14px; }
body.auth-compact .auth-pill { margin-top: 8px; }
body.auth-compact .auth-card { margin-top: -56px; padding: 26px 28px 22px; }
body.auth-compact .auth-card-subtitle { margin-bottom: 18px; }
body.auth-compact .auth-field { margin-bottom: 12px; }
body.auth-compact .auth-submit { min-height: 48px; margin-top: 6px; }
body.auth-compact .auth-links { margin-top: 12px; }
body.auth-compact .auth-note { margin-top: 8px; margin-bottom: 0; }
/* Footer on one line: "Powered by [Allvy] · © ..." */
body.auth-compact .auth-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px;
  padding: 12px 16px 14px;
}
body.auth-compact .auth-powered { margin: 0; }
body.auth-compact .auth-footer img { width: 110px; height: 26px; }
body.auth-compact .auth-copy { margin: 0; }

@media (min-width: 768px) {
  body.auth-compact .auth-hero { padding-top: 28px; padding-bottom: 84px; }
  body.auth-compact .auth-emblem-ring { width: 116px; height: 116px; }
  body.auth-compact .auth-emblem-ring img { width: 102px; height: 102px; }
  body.auth-compact .auth-title { font-size: 28px; }
  body.auth-compact .auth-card { margin-top: -60px; }
}

/* Short screens (small laptops, landscape phones): tighten further; scroll only if still too short. */
@media (max-height: 760px) {
  body.auth-compact .auth-page { height: auto; min-height: 100vh; }
  body.auth-compact .auth-hero { padding-top: 16px; padding-bottom: 64px; }
  body.auth-compact .auth-emblem-ring { width: 92px; height: 92px; margin-bottom: 6px; }
  body.auth-compact .auth-emblem-ring img { width: 80px; height: 80px; }
  body.auth-compact .auth-title { font-size: 22px; }
  body.auth-compact .auth-pill { display: none; }
  body.auth-compact .auth-card { margin-top: -48px; padding-top: 20px; padding-bottom: 18px; }
}

@media (max-width: 420px) {
  .auth-lang-toggle { top: 14px; right: 14px; }
  .auth-card-title.auth-has-toggle { padding-right: 112px; font-size: 20px; }
}
