/* =============================================================================
 * 自包含 Account 頁樣式（#8）：登入 / 登出 / 切換租戶共用。
 * 不依賴 Bootstrap / LeptonX；同源、零外部字型；對應 strict CSP style-src 'self'。
 * 品牌色票沿用既有 global-styles.css：teal #00c1b6、link #43A6ED、deep #25608A。
 * ============================================================================= */

:root {
  --brand: #00c1b6;
  --brand-dark: #00a89e;
  --brand-deep: #25608a;
  --link: #43a6ed;
  --ink: #2f2f2f;
  --muted: #6b7785;
  --line: #e6e9ee;
  --field-bg: #eef1f5;
  --card-bg: #ffffff;
  --danger: #d6336c;
  --danger-bg: #fdecf2;
  --warning: #9a6700;
  --warning-bg: #fff6e0;
  --info: #1565a8;
  --info-bg: #e7f1fb;
  --success: #1c7c54;
  --success-bg: #e6f5ee;
  --radius: 14px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.account-page {
  margin: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background-color: #cdd9f7;
  background-image: url("/LeptonX/images/login-pages/login-bg-img-light.svg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

.account-shell {
  width: 100%;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.account-brand {
  height: 66px;
  width: auto;
  object-fit: contain;
}

.account-card {
  width: 100%;
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(20, 40, 80, 0.16);
  padding: 2rem 2.1rem;
}

/* 視覺隱藏但保留給輔助技術（原版欄位無可見 label，只有 placeholder）。 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.account-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.account-card__title {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.account-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.1rem 0;
}

/* ---- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}
.btn--sm { padding: 0.35rem 0.85rem; font-size: 0.85rem; }
.btn--block { width: 100%; margin-top: 0.4rem; padding: 0.8rem 1rem; font-size: 1.05rem; }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--secondary { background: var(--brand-deep); color: #fff; }
.btn--secondary:hover { filter: brightness(1.06); }
.btn--outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn--outline:hover { background: var(--brand); color: #fff; }
.btn--light { background: #eef1f5; color: var(--ink); border-color: transparent; }
.btn--light:hover { background: #e3e7ee; }

/* ---- Language switch (pure CSS <details>) ---------------------------------- */
.lang { position: relative; }
.lang__toggle { list-style: none; white-space: nowrap; }
.lang__toggle::-webkit-details-marker { display: none; }
.lang__list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  min-width: 12rem;
  max-height: 16rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(20, 40, 80, 0.16);
}
.lang__item {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}
.lang__item:hover { background: #f1f4f8; }
.icon { width: 1em; height: 1em; flex: none; }
.icon--caret { width: 0.8em; height: 0.8em; opacity: 0.7; }
.icon[hidden] { display: none; }

/* ---- Modal（JS 驅動，hidden 開關；租戶切換用） ------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: rgba(20, 30, 55, 0.5);
}
.modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 26rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 70px rgba(20, 40, 80, 0.3);
  padding: 1.6rem 1.6rem 1.4rem;
}
.modal__title { margin: 0 0 1.1rem; font-size: 1.3rem; font-weight: 800; }

/* ---- Tenant box ------------------------------------------------------------ */
.tenant { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.tenant__label { font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.tenant__name { font-size: 1.05rem; margin-top: 0.15rem; }

/* ---- Alerts / validation --------------------------------------------------- */
.alert {
  padding: 0.7rem 0.9rem;
  border-radius: 9px;
  margin-bottom: 0.85rem;
  font-size: 0.95rem;
  border: 1px solid transparent;
}
.alert:empty { display: none; }
.alert--danger { background: var(--danger-bg); color: var(--danger); border-color: #f3c2d4; }
.alert--warning { background: var(--warning-bg); color: var(--warning); border-color: #f3e2b0; }
.alert--info { background: var(--info-bg); color: var(--info); border-color: #c2ddf3; }
.alert--success { background: var(--success-bg); color: var(--success); border-color: #bfe6d2; }
.alert--default, .alert--primary, .alert--secondary, .alert--light, .alert--dark {
  background: #f1f4f8; color: var(--ink); border-color: var(--line);
}
.account-validation-summary ul { margin: 0; padding-left: 1.1rem; }
.account-validation-summary[hidden] { display: none; }

.account-register-line { margin: 0 0 1rem; }
.account-register-line a, .account-form__link a, a.account-form__link { color: var(--link); }

/* ---- Form fields ----------------------------------------------------------- */
.account-form { margin: 0; }
.field { margin-bottom: 0.9rem; }
.field__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.field__control { position: relative; }
.field__input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.field__control .field__input { padding-right: 3rem; }
.field__input::placeholder { color: #9aa4b1; }
.field__input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(0, 193, 182, 0.15); }
.field__addon {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.field__addon .icon { width: 1.05rem; height: 1.05rem; }
.field__error { display: block; color: var(--danger); font-size: 0.85rem; margin-top: 0.3rem; }
.field__error:empty { display: none; }
.field__hint { color: var(--warning); font-size: 0.85rem; margin: 0.3rem 0 0; }
.field__hint[hidden] { display: none; }

.account-form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.4rem 0 1.1rem;
}
.account-form__link { color: var(--link); text-decoration: none; font-size: 0.95rem; }
.account-form__link:hover { text-decoration: underline; }

/* ---- Remember-me switch ---------------------------------------------------- */
.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; user-select: none; }
.switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  width: 2.4rem;
  height: 1.35rem;
  border-radius: var(--radius-pill);
  background: #cfd6df;
  transition: background-color 0.15s;
  flex: none;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch__input:checked + .switch__track { background: var(--brand); }
.switch__input:checked + .switch__track::after { transform: translateX(1.05rem); }
.switch__input:focus-visible + .switch__track { box-shadow: 0 0 0 3px rgba(0, 193, 182, 0.25); }
.switch__label { font-size: 0.95rem; }

/* ---- External providers ---------------------------------------------------- */
.account-external { margin-top: 1.25rem; }
.account-external__sep {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
.account-external__sep::before,
.account-external__sep::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}
.account-external__sep span { padding: 0 0.75rem; }
.account-external__list { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---- LoggedOut ------------------------------------------------------------- */
.account-card__text { color: var(--muted); margin: 0.5rem 0 1.25rem; }
.signout-frame { width: 0; height: 0; border: 0; position: absolute; }

@media (max-width: 480px) {
  .account-card { padding: 1.25rem; }
  .account-card__title { font-size: 1.5rem; }
}
