/* --- FIX: remove default browser margin that exposes white html background on sides/bottom --- */
html, body.auth-page {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
}

html {
  background: #070809;
}

/* Auth — biến màu gắn .auth-page (không đè :root / trang chủ) */
.auth-page {
  --lp-green: #22c55e;
  --lp-green-dark: #4ade80;
  --lp-green-light: #86efac;
  --lp-green-50: rgba(34, 197, 94, 0.14);
  --lp-green-100: rgba(34, 197, 94, 0.22);
  --lp-green-200: rgba(34, 197, 94, 0.4);
  --lp-white: #12151a;
  --lp-bg: #070809;
  --lp-line: rgba(255, 255, 255, 0.1);
  --lp-text: #f2f4f6;
  --lp-text-2: #d5dae0;
  --lp-text-3: #9aa3ad;
  --lp-radius: 12px;
  --lp-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.45);
  --lp-font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --fx-chrome-light: #070809;
  font-family: var(--lp-font);
  min-height: 100vh;
  color: var(--lp-text-2);
  -webkit-font-smoothing: antialiased;
  background: var(--lp-bg) !important;
  color-scheme: dark;
}

.hidden {
  display: none !important;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(34, 197, 94, 0.14), transparent 55%),
    radial-gradient(ellipse 40% 35% at 0% 100%, rgba(255, 255, 255, 0.03), transparent 50%),
    var(--lp-bg);
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (min-width: 900px) {
  .auth-shell {
    grid-template-columns: minmax(300px, 40%) 1fr;
  }
}

.auth-showcase {
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 3rem clamp(2rem, 4vw, 3rem);
  border-right: 1px solid var(--lp-line);
  background: linear-gradient(180deg, var(--lp-green-50) 0%, var(--lp-white) 100%);
}

@media (min-width: 900px) {
  .auth-showcase {
    display: flex;
  }
}

.auth-showcase-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 2.5rem;
  text-decoration: none;
}

.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  background: var(--lp-green);
}

.auth-brand-text {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--lp-text);
}

.auth-brand-supper {
  color: var(--lp-green-dark);
  font-weight: 800;
}

.auth-showcase-title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.375rem, 2.5vw, 1.75rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--lp-text);
}

.auth-showcase-lead {
  margin: 0 0 2rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--lp-text-3);
  max-width: 20rem;
}

.auth-showcase-list {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-showcase-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--lp-text-2);
}

.auth-showcase-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--lp-green-dark);
  background: var(--lp-green-50);
  border: 1px solid var(--lp-green-200);
}

.auth-showcase-note {
  margin: 0;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--lp-text-3);
  line-height: 1.5;
}

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem clamp(0.875rem, 3vw, 1.5rem) 1.5rem;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-back {
  position: fixed;
  top: calc(1.75rem + env(safe-area-inset-top, 0px));
  left: 1rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--lp-line);
  background: rgba(18, 21, 26, 0.92);
  backdrop-filter: blur(8px);
  color: var(--lp-text-3);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

@media (min-width: 900px) {
  .auth-back {
    position: absolute;
    top: calc(2rem + env(safe-area-inset-top, 0px));
    left: 1.5rem;
  }
}

.auth-back:hover {
  background: var(--lp-green-50);
  border-color: var(--lp-green-200);
  color: var(--lp-green-dark);
}

.auth-panel {
  position: relative;
  width: 100%;
  max-width: 25.5rem;
  padding: 1.85rem 1.6rem 1.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: rgba(18, 21, 26, 0.85);
  backdrop-filter: blur(35px);
  -webkit-backdrop-filter: blur(35px);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.auth-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--lp-green), transparent);
  opacity: 0.9;
}

.auth-panel--wide {
  max-width: 480px;
}

.auth-panel h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--lp-text);
}

.auth-lead {
  margin: 0 0 1.15rem;
  font-size: 0.875rem;
  color: var(--lp-text-3);
  line-height: 1.45;
}

/* iOS Segmented Control Tab */
.auth-tabs {
  display: flex;
  background: rgba(120, 120, 128, 0.2);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-tabs a {
  flex: 1;
  padding: 0.52rem 0.85rem;
  min-height: 2.15rem;
  border-radius: 9px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--lp-text-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-tabs a:hover:not(.active) {
  color: #fff;
}

.auth-tabs a.active {
  color: #000000;
  background: #ffffff;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22), 0 1px 2px rgba(0, 0, 0, 0.12);
}

.auth-form {
  display: flex;
  flex-direction: column;
  margin-top: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.auth-field {
  margin-bottom: 0.85rem;
}

.auth-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .auth-field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.auth-field label,
.auth-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lp-text-2);
}

.auth-input-wrap {
  position: relative;
}

.auth-input-wrap input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(118, 118, 128, 0.14);
  color: #ffffff;
  font-family: inherit;
  font-size: 16px; /* 16px ngăn chặn iOS tự động phóng to màn hình */
  outline: none;
  transition: all 0.18s ease;
  box-sizing: border-box;
  -webkit-appearance: none;
}

.auth-input-wrap input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.auth-input-wrap input:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.auth-input-wrap input:focus {
  border-color: var(--lp-green);
  background: rgba(118, 118, 128, 0.22);
  box-shadow: 0 0 0 3.5px rgba(34, 197, 94, 0.22);
}

.auth-field.is-error input {
  border-color: #e57373;
  box-shadow: 0 0 0 2px rgba(229, 115, 115, 0.12);
}

.auth-field-error {
  min-height: 1.1em;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #c62828;
}

.auth-toggle-pw {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.auth-toggle-pw::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236d7f76' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M15 12a3 3 0 11-6 0 3 3 0 016 0z'/%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z'/%3E%3C/svg%3E");
}

.auth-toggle-pw.is-visible::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236d7f76' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21'/%3E%3C/svg%3E");
}

.auth-toggle-pw:hover {
  opacity: 1;
  background: var(--lp-green-50);
}

.auth-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  color: var(--lp-text-3);
  cursor: pointer;
}

.auth-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--lp-green);
}

.auth-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.auth-plan-opt {
  position: relative;
}

.auth-plan-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.auth-plan-opt label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.7rem 0.3rem;
  border: 1px solid var(--lp-line);
  border-radius: 8px;
  background: var(--lp-white);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  margin: 0;
}

.auth-plan-opt label strong {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--lp-text);
}

.auth-plan-opt label span {
  font-size: 0.625rem;
  color: var(--lp-text-3);
}

.auth-plan-opt input:checked + label {
  border-color: var(--lp-green);
  background: var(--lp-green-50);
}

.auth-plan-opt--pro input:checked + label {
  border-color: var(--lp-green-dark);
  background: var(--lp-green-100);
}

.auth-plan-opt label:hover {
  border-color: var(--lp-green-200);
}

.auth-alert {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  border: 1px solid #ef9a9a;
  background: #ffebee;
  color: #c62828;
}

.auth-alert.ok {
  border-color: #a5d6a7;
  background: #e8f5e9;
  color: #2e7d32;
}

.auth-submit {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  margin-top: 0.5rem;
  padding: 0.85rem 1.25rem;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 50px;
  transition: all 0.15s ease;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
  -webkit-tap-highlight-color: transparent;
}

.auth-submit:active:not(:disabled) {
  transform: scale(0.985);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25);
}

.auth-submit:hover:not(:disabled) {
  filter: brightness(1.05);
}

.auth-submit:disabled,
.auth-submit.is-loading {
  opacity: 0.65;
  cursor: wait;
}

.auth-submit-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 50px;
  font-size: 1rem;
  font-weight: 700;
}

.auth-submit-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.65s linear infinite;
}

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

.auth-foot {
  margin: 0.875rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--lp-text-3);
}

.auth-foot a {
  color: var(--lp-green-dark);
  font-weight: 600;
  text-decoration: none;
}

.auth-foot a:hover {
  text-decoration: underline;
}

.auth-note {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--lp-text-3);
  line-height: 1.45;
}

@media (max-width: 899px) {
  .auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.875rem;
    text-decoration: none;
  }

  .auth-mobile-brand .auth-brand-text {
    font-size: 1.25rem;
  }
}

@media (min-width: 900px) {
  .auth-mobile-brand {
    display: none;
  }
}

/* =========================================================
   CHUẨN GIAO DIỆN APPLE iOS CHO IPHONE & MOBILE (FULL SCREEN)
   ========================================================= */
@media (max-width: 600px) {
  body.auth-page {
    background: #000000 !important;
    overflow-x: hidden;
  }

  .auth-bg {
    opacity: 0.45;
  }

  .auth-shell {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
  }

  .auth-main {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
  }

  /* Nút Back phong cách iOS Navigation Bar */
  .auth-back {
    position: fixed;
    top: calc(env(safe-area-inset-top, 14px) + 8px);
    left: 14px;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(120, 120, 128, 0.25);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    color: #34c759;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
  }

  .auth-back:active {
    transform: scale(0.96);
    background: rgba(120, 120, 128, 0.4);
  }

  /* Panel đăng nhập / đăng ký full kích thước màn hình iPhone */
  .auth-panel {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    padding: calc(env(safe-area-inset-top, 16px) + 52px) 1.25rem calc(env(safe-area-inset-bottom, 20px) + 24px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .auth-panel::before {
    display: none;
  }

  .auth-mobile-brand {
    margin: 0 auto 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .auth-panel h1 {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #ffffff;
    margin-bottom: 0.35rem;
  }

  .auth-lead {
    font-size: 0.925rem;
    color: #8e8e93;
    margin-bottom: 1.25rem;
  }

  /* iOS Segmented Control */
  .auth-tabs {
    display: flex;
    background: rgba(120, 120, 128, 0.24);
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 1.5rem;
    border: none;
  }

  .auth-tabs a {
    flex: 1;
    min-height: 36px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.65);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .auth-tabs a.active {
    color: #000000;
    background: #ffffff;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.1);
  }

  /* Nhãn và Input form chuẩn iOS */
  .auth-field {
    margin-bottom: 1rem;
  }

  .auth-field label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8e8e93;
    margin-bottom: 0.4rem;
  }

  .auth-input-wrap input {
    width: 100%;
    min-height: 52px;
    height: 52px;
    background: #1c1c1e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0 14px;
    font-size: 16px; /* Ngăn Safari tự phóng to màn hình */
    color: #ffffff;
    box-sizing: border-box;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  }

  .auth-input-wrap input:focus {
    background: #242426;
    border-color: #34c759;
    box-shadow: 0 0 0 3.5px rgba(52, 199, 89, 0.22);
  }

  .auth-toggle-pw {
    width: 40px;
    height: 40px;
    right: 6px;
  }

  .auth-check {
    margin: 0.25rem 0 1rem;
    font-size: 0.85rem;
    color: #aeaeb2;
  }

  .auth-check input {
    width: 18px;
    height: 18px;
  }

  /* Nút CTA chuẩn iOS Filled Button */
  .auth-submit {
    width: 100%;
    min-height: 52px;
    border-radius: 14px;
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
    margin-top: 0.75rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .auth-submit:active:not(:disabled) {
    transform: scale(0.985);
    filter: brightness(0.95);
  }

  .auth-submit-label {
    min-height: 52px;
    font-size: 1.05rem;
    font-weight: 600;
  }

  .auth-foot {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: #8e8e93;
    text-align: center;
  }

  .auth-foot a {
    color: #34c759;
    font-weight: 600;
  }
}

@media (max-width: 400px) {
  .auth-plans {
    grid-template-columns: 1fr;
  }
}

/* Safari chrome — status bar liền mạch chuẩn iOS Dark Mode */
#fx-safari-chrome-top {
  display: none !important;
}

@supports (-webkit-touch-callout: none) {
  body.auth-page {
    background: #000000 !important;
  }

  .auth-bg {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-submit-spinner {
    animation: none;
  }
}
