/* =======================================================
   auth.css - Login + Reset
   ======================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body.auth-login {
  margin: 0;
  width: 100%;
  height: 100%;
}

html {
  background: #f5f7fa;
}

:root {
  --primary: #003345;
  --primary-container: #004b63;
  --secondary: #505f76;
  --tertiary: #003530;
  --surface: #f5f7fa;
  --text-primary: #181c20;
  --success: #07c8b8;
  --danger: #ba1a1a;
  --text-100: #f5f7fa;
}

@keyframes smFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =========================
   Login
   ========================= */
body.auth-login {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  height: 100svh;
  min-height: 100dvh;
  height: 100dvh;
  font-family: "Inter", "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  background: var(--surface);
  overflow: hidden;
}

.auth-login-layout {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  animation: smFade 0.22s ease-out both;
}

.auth-brand-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 62px;
  background:
    radial-gradient(120% 85% at 16% 10%, rgba(0, 75, 99, 0.6), rgba(0, 75, 99, 0) 58%),
    linear-gradient(145deg, #003345, #004b63 56%, #003530);
  color: var(--text-100);
}

.auth-brand-panel::before {
  content: "";
  position: absolute;
  top: -18%;
  right: -12%;
  width: 68%;
  height: 58%;
  background: radial-gradient(circle, rgba(7, 200, 184, 0.26), rgba(7, 200, 184, 0) 72%);
  opacity: 0.46;
  pointer-events: none;
}

.auth-brand-panel::after {
  content: "";
  position: absolute;
  left: -24%;
  bottom: -34%;
  width: 135%;
  height: 82%;
  background: radial-gradient(ellipse at center, rgba(7, 200, 184, 0.24), rgba(7, 200, 184, 0) 68%);
  transform: rotate(-12deg);
  pointer-events: none;
}

.auth-brand-inner {
  position: relative;
  z-index: 2;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-brand-bg-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.96;
  filter: brightness(1.05);
  pointer-events: none;
  z-index: 1;
}

.auth-brand-text {
  display: grid;
  gap: 3px;
  align-content: start;
}

.auth-brand-title {
  margin: 0;
  font-size: clamp(1.88rem, 4.8vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: 0.01em;
  font-weight: 700;
  color: rgba(245, 247, 250, 0.94);
}

.auth-brand-sub {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.2;
  letter-spacing: 0.17em;
  font-weight: 600;
  color: rgba(245, 247, 250, 0.64);
  text-transform: uppercase;
}

.auth-brand-note {
  margin: 12px 0 0;
  max-width: 340px;
  font-size: 0.94rem;
  line-height: 1.55;
  color: rgba(245, 247, 250, 0.68);
  font-weight: 400;
}

.auth-form-panel {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 56px;
}

.auth-form-shell {
  width: 100%;
  max-width: 404px;
}

.auth-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  font-weight: 700;
}

.auth-subtitle {
  margin: 8px 0 28px;
  color: var(--secondary);
  font-size: 0.82rem;
  line-height: 1.5;
  font-weight: 400;
}

.auth-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 0.84rem;
  font-weight: 600;
}

.auth-alert-error {
  color: var(--danger);
  background: rgba(186, 26, 26, 0.12);
  box-shadow: inset 0 0 0 1px rgba(186, 26, 26, 0.22);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-passkey-block {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-passkey-primary {
  width: 100%;
  border: 1px solid rgba(0, 75, 99, 0.28);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 75, 99, 0.12), rgba(0, 53, 48, 0.14));
  color: #003345;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 11px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.auth-passkey-primary:hover {
  filter: brightness(1.03);
  box-shadow: 0 8px 18px rgba(0, 51, 69, 0.12);
}

.auth-passkey-primary:active {
  transform: translateY(0.5px);
}

.auth-passkey-primary:disabled {
  opacity: 0.68;
  cursor: wait;
}

.auth-passkey-primary.is-loading i {
  animation: authPasskeyPulse 0.8s ease-in-out infinite alternate;
}

@keyframes authPasskeyPulse {
  from { transform: scale(1); opacity: 0.75; }
  to { transform: scale(1.1); opacity: 1; }
}

.auth-mobile-suggested-trigger {
  display: none;
  width: 100%;
  height: 40px;
  border: 1px solid rgba(80, 95, 118, 0.24);
  border-radius: 10px;
  background: #ffffff;
  color: #425266;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.auth-passkey-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 58px;
  height: 58px;
  border: 1px solid rgba(0, 75, 99, 0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, #003345, #004b63);
  color: #f5f7fa;
  box-shadow: 0 16px 30px rgba(0, 51, 69, 0.28);
  z-index: 50;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.auth-passkey-fab i {
  font-size: 1.2rem;
}

.auth-passkey-fab.is-loading i {
  animation: authPasskeyPulse 0.8s ease-in-out infinite alternate;
}

.auth-brand-accounts {
  width: min(360px, 100%);
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.auth-brand-accounts-title {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 247, 250, 0.72);
  font-weight: 700;
}

.auth-brand-accounts-list {
  display: grid;
  gap: 10px;
}

.auth-brand-account-card {
  width: 100%;
  border: 1px solid rgba(245, 247, 250, 0.22);
  border-radius: 14px;
  background: rgba(0, 21, 30, 0.4);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f5f7fa;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.auth-brand-account-card:hover {
  border-color: rgba(7, 200, 184, 0.58);
  background: rgba(0, 21, 30, 0.58);
  transform: translateY(-1px);
}

.auth-brand-account-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  flex: 0 0 auto;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(245, 247, 250, 0.38);
  background: rgba(245, 247, 250, 0.18);
}

.auth-brand-account-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-brand-account-initials {
  font-size: 0.8rem;
  line-height: 1;
  color: rgba(245, 247, 250, 0.92);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.auth-brand-account-name {
  min-width: 0;
  font-size: 0.9rem;
  color: #f5f7fa;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-mobile-accounts-dock {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  padding: 8px 10px;
  border: 1px solid rgba(80, 95, 118, 0.28);
  border-radius: 16px;
  background: rgba(245, 247, 250, 0.96);
  backdrop-filter: blur(9px);
  box-shadow: 0 14px 30px rgba(24, 28, 32, 0.18);
}

.auth-mobile-accounts-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.auth-mobile-account-icon {
  border: 1px solid rgba(80, 95, 118, 0.22);
  background: #ffffff;
  border-radius: 12px;
  padding: 6px 4px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #223247;
  cursor: pointer;
}

.auth-mobile-account-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(80, 95, 118, 0.26);
  background: rgba(0, 75, 99, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.auth-mobile-account-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-mobile-account-initials {
  font-size: 0.7rem;
  font-weight: 700;
  color: #173043;
}

.auth-mobile-account-label {
  width: 100%;
  text-align: center;
  font-size: 0.63rem;
  line-height: 1.05;
  color: #2e435c;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-mobile-account-more .auth-mobile-account-avatar {
  background: rgba(0, 75, 99, 0.12);
  color: #003345;
}

.auth-mobile-accounts-sheet {
  position: fixed;
  inset: 0;
  z-index: 56;
}

.auth-mobile-accounts-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
}

.auth-mobile-accounts-sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px 20px 0 0;
  border: 1px solid rgba(80, 95, 118, 0.2);
  background: #ffffff;
  box-shadow: 0 -10px 36px rgba(24, 28, 32, 0.24);
  padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: min(70vh, 430px);
  overflow: auto;
}

.auth-mobile-accounts-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
}

.auth-mobile-accounts-sheet-head strong {
  font-size: 0.9rem;
  color: #182334;
}

.auth-mobile-accounts-sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(80, 95, 118, 0.25);
  background: #ffffff;
  color: #223247;
  cursor: pointer;
}

.auth-mobile-accounts-sheet-list {
  display: grid;
  gap: 8px;
}

.auth-mobile-account-row {
  width: 100%;
  border: 1px solid rgba(80, 95, 118, 0.22);
  border-radius: 12px;
  background: #f9fbfd;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: #182334;
  cursor: pointer;
}

.auth-mobile-account-row-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(80, 95, 118, 0.24);
  background: rgba(0, 75, 99, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.auth-mobile-account-row-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-mobile-account-row-initials {
  font-size: 0.72rem;
  font-weight: 700;
  color: #173043;
}

.auth-mobile-account-row-body {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.auth-mobile-account-row-body strong {
  font-size: 0.82rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-mobile-account-row-body small {
  font-size: 0.7rem;
  color: #4e6077;
}

body.auth-mobile-sheet-open {
  overflow: hidden;
}

.auth-field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--secondary);
  font-weight: 700;
}

.auth-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 2px 0 0;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 -1px 0 rgba(80, 95, 118, 0.3);
  transition: box-shadow 0.14s ease;
}

.auth-input-wrap:focus-within {
  box-shadow:
    inset 0 -2px 0 rgba(0, 75, 99, 0.7),
    0 5px 14px rgba(0, 51, 69, 0.08);
}

.auth-input-wrap > i {
  color: rgba(80, 95, 118, 0.9);
  font-size: 0.9rem;
  flex: 0 0 auto;
}

.auth-input-wrap input {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 500;
  outline: none;
}

.auth-input-wrap input::placeholder {
  color: rgba(80, 95, 118, 0.62);
  font-weight: 400;
}

.auth-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 0;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-size: 0.68rem;
  font-weight: 500;
}

.auth-check input {
  width: 13px;
  height: 13px;
  accent-color: var(--primary-container);
}

.auth-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
}

.auth-link:hover {
  color: var(--primary-container);
  text-decoration: underline;
}

.auth-submit {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 5px;
  background: linear-gradient(135deg, #003345, #004b63);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.01em;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 6px 14px rgba(0, 51, 69, 0.18);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.auth-submit:hover { filter: brightness(1.04); }
.auth-submit:active { transform: translateY(0.5px); }

.auth-support-note {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.68rem;
  color: var(--secondary);
}

.auth-support-note a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-support-note a:hover {
  color: var(--primary-container);
  text-decoration: underline;
}

@media (max-width: 960px) {
  .auth-login-layout { grid-template-columns: 1fr; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { padding: 26px 22px 108px; }
  .auth-passkey-primary { display: none; }
  .auth-passkey-fab { display: inline-flex; }
  .auth-mobile-suggested-trigger:not(.d-none) { display: inline-flex; }
}

@media (max-width: 520px) {
  .auth-form-panel { padding: 20px 16px; }
  .auth-form-shell { max-width: 420px; }
  .auth-title { font-size: 1.72rem; }
  .auth-meta-row { flex-wrap: wrap; row-gap: 8px; }
  .auth-form-panel { padding-bottom: 102px; }
}

/* =========================
   Reset password
   ========================= */
body.auth-reset {
  margin: 0;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: "Inter", "Manrope", "Segoe UI", system-ui, sans-serif;
  color: var(--text-100);
  background:
    radial-gradient(900px 520px at 15% 10%, rgba(0, 75, 99, 0.24), transparent 62%),
    radial-gradient(900px 520px at 85% 14%, rgba(7, 200, 184, 0.12), transparent 60%),
    linear-gradient(180deg, #003345, #003530);
}

.auth-reset .card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, rgba(0, 51, 69, 1), rgba(0, 53, 48, 1));
  border: 1px solid rgba(80, 95, 118, 0.34);
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: smFade 0.28s ease-out;
}

.auth-reset .card-head {
  padding: 22px 24px 18px;
  text-align: center;
  background: linear-gradient(135deg, rgba(0, 75, 99, 0.52), rgba(0, 53, 48, 0.38));
}

.auth-reset .card-head h3 {
  margin: 0;
  font-weight: 700;
  color: #f5f7fa;
  font-size: 1.15rem;
}

.auth-reset .card-head p {
  margin: 6px 0 0;
  color: rgba(245, 247, 250, 0.8);
  font-size: 0.9rem;
}

.auth-reset .card-body { padding: 24px; }

.auth-reset label {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  color: rgba(245, 247, 250, 0.88);
  margin-bottom: 6px;
}

.auth-reset input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: 13px;
  outline: none;
  border: 1px solid rgba(80, 95, 118, 0.42);
  background: rgba(245, 247, 250, 0.08);
  color: #f5f7fa;
  font-size: 0.95rem;
  transition: border-color 0.15s;
}

.auth-reset input[type="password"]:focus {
  border-color: rgba(7, 200, 184, 0.65);
}

.auth-reset .mb { margin-bottom: 16px; }

.auth-reset .btn {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(245, 247, 250, 0.18);
  border-radius: 13px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  background: linear-gradient(135deg, #003345, #004b63);
  color: #f5f7fa;
  margin-top: 4px;
  transition: filter 0.15s;
}

.auth-reset .btn:hover { filter: brightness(1.08); }
.auth-reset .btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-reset .alert {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  border: 1px solid;
}

.auth-reset .alert-err {
  background: rgba(186, 26, 26, 0.14);
  border-color: rgba(186, 26, 26, 0.3);
  color: #f5f7fa;
}

.auth-reset .alert-ok {
  background: rgba(7, 200, 184, 0.14);
  border-color: rgba(7, 200, 184, 0.3);
  color: #f5f7fa;
}

.auth-reset .link-back {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 0.86rem;
  color: rgba(245, 247, 250, 0.7);
  text-decoration: none;
}

.auth-reset .link-back:hover {
  color: #07c8b8;
}
