/* ================================================================
   TDH Portal — auth.css
   ----------------------------------------------------------------
   สไตล์เฉพาะหน้า auth (login / forgot / reset) แบบ split-screen
   ตามแบบที่ออกไว้: ครึ่งซ้ายเป็นแผงแบรนด์สีน้ำเงิน ครึ่งขวาเป็นฟอร์มบนพื้นสว่าง

   ยืนบน Bootstrap 5.3.3 (CDN) ไม่ใช่เทมเพลต Cuba และใช้ฟอนต์ Prompt ตามแบรนด์
   โหลดเฉพาะในวิว auth จึงไม่กระทบ style.css กลาง
   token ที่นิยามเพิ่มถูก scope ไว้ใต้ .auth-shell เท่านั้น
   ================================================================ */

.auth-shell {
  /* แกนสีน้ำเงินจากแบรนด์ TDH */
  --brand: #1a4d95;
  --brand-600: #0d3266;
  --brand-400: #2563b0;
  --brand-rgb: 26, 77, 149;
  --ink: #14243d;
  --muted: #6b7a90;
  --field-bg: #f3f7fd;
  --field-border: #e3ebf7;

  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #fff;
  overflow: hidden;
  font-family: 'Prompt', sans-serif;
  color: var(--ink);
}

/* ================= ฝั่งซ้าย: แผงแบรนด์ ================= */
.auth-brand {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: clamp(2.5rem, 4.2vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  color: #fff;
  background:
    radial-gradient(90% 70% at 18% 8%, #2a6ec4 0%, transparent 55%),
    linear-gradient(140deg, #1552a8 0%, #123f86 45%, #0c2f66 100%);
}

/* วงกลมเบลอให้พื้นหลังมีมิติ */
.auth-brand::before {
  content: "";
  position: absolute;
  width: 460px; height: 460px;
  top: -160px; right: -140px;
  border-radius: 50%;
  background: #4a9de0;
  filter: blur(80px);
  opacity: .35;
  pointer-events: none;
}

.auth-brand > * { position: relative; z-index: 1; }

/* เส้นโค้งพื้นหลัง วาดเป็น SVG จริง (ดู _head.php)
   เคยลองทำด้วย gradient แล้วได้แค่วงรีซ้อนกัน ไม่ได้ทรงเส้นสวบตามแบบ
   ต้องประกาศ "หลัง" .auth-brand > * ไม่งั้นโดนทับเป็น position:relative แล้วกลายเป็น flex item ดันเลย์เอาต์เพี้ยน */
.auth-brand__curves {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* จับข้อความหลักกับจุดขายไว้เป็นก้อนเดียว จะได้ไม่ถูก space-between ดันห่างกันเกินไป */
.auth-brand__body {
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

/* ตารางจุดมุมล่างซ้าย */
.auth-brand__dots {
  position: absolute;
  left: 0;
  bottom: 5.5rem;
  width: 190px;
  height: 210px;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .28) 1.4px, transparent 1.4px);
  background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(100deg, #000 10%, transparent 75%);
          mask-image: linear-gradient(100deg, #000 10%, transparent 75%);
  pointer-events: none;
}

/* ---- ล็อกอัปโลโก้ด้านบน ---- */
.auth-brand__logo {
  display: flex;
  align-items: center;
  gap: .9rem;
}
.auth-brand__mark {
  width: 44px;
  height: auto;
  /* โลโก้ต้นฉบับเป็นสีน้ำเงิน วางบนพื้นน้ำเงินแล้วจม จึงกลับเป็นสีขาวล้วน */
  filter: brightness(0) invert(1);
}
.auth-brand__name {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  letter-spacing: .5px;
}
.auth-brand__name strong { font-size: 1.35rem; font-weight: 700; }
.auth-brand__name small  { font-size: .95rem; font-weight: 300; color: rgba(255, 255, 255, .8); }
.auth-brand__sep {
  width: 1px;
  height: 34px;
  background: rgba(255, 255, 255, .3);
  margin: 0 .35rem;
}
.auth-brand__app {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: .3px;
}

/* ---- ข้อความหลัก ----
   ความกว้างคุมเป็น rem ไม่ใช้ ch เพราะ ch คิดจาก font-size ของกล่องเอง (16px)
   ไม่ใช่ของ h1 ที่อยู่ข้างใน — ใช้ ch แล้วหัวข้อจะถูกบีบจนตัดบรรทัดทีละคำ */
.auth-brand__hero { max-width: 27rem; }
.auth-brand__hero h1 {
  max-width: 21rem;   /* คุมให้ตัดบรรทัดเป็น 2 บรรทัดตามแบบ */
  font-size: clamp(2rem, 3.1vw, 2.85rem);
  line-height: 1.3;
  font-weight: 700;
  margin: 0 0 1.15rem;
}
.auth-brand__hero p {
  max-width: 25rem;
  font-size: 1.02rem;
  line-height: 1.75;
  font-weight: 300;
  color: rgba(255, 255, 255, .85);
  margin: 0;
}

/* ---- จุดขาย 3 ข้อ ---- */
.auth-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.65rem;
}
.auth-features li {
  display: flex;
  align-items: center;
  gap: 1.05rem;
}
.auth-features__ico {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 1.4rem;
  color: #fff;
}
.auth-features__text { display: flex; flex-direction: column; gap: .18rem; }
.auth-features__text strong {
  font-size: 1.02rem;
  font-weight: 600;
  color: #fff;
}
.auth-features__text small {
  font-size: .85rem;
  font-weight: 300;
  color: rgba(255, 255, 255, .68);
}

/* ---- ท้ายแผงซ้าย ---- */
.auth-brand__foot {
  font-size: .82rem;
  font-weight: 300;
  color: rgba(255, 255, 255, .58);
  line-height: 1.9;
}
.auth-brand__foot a {
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
}
.auth-brand__foot a:hover { color: #fff; text-decoration: underline; }
.auth-brand__foot .sep { margin: 0 .5rem; opacity: .45; }

/* ================= ฝั่งขวา: ฟอร์ม ================= */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  /* grid/flex item ปกติมี min-width:auto ทำให้ยุบเล็กกว่า min-content ของข้อความไม่ได้
     พอจอแคบคอลัมน์เลยกว้างเกินจอแล้วโดน overflow:hidden ของ .auth-shell ตัดทิ้ง */
  min-width: 0;
  padding: clamp(1.5rem, 4vw, 3rem);
  background:
    radial-gradient(90% 55% at 50% 0%, #eef4fd 0%, transparent 65%),
    #fbfcfe;
}

.auth-card {
  width: 100%;
  min-width: 0;
  max-width: 510px;
}

/* โลโก้เต็มของบริษัท (ตัวฟัน + TDH THONGLOR DENTAL HOSPITAL CO.,LTD.)
   ต้องกว้างพอสมควรไม่งั้นบรรทัดชื่อเต็มด้านล่างจะเล็กจนอ่านไม่ออก */
.auth-card__logo {
  display: block;
  width: 150px;
  max-width: 68%;
  height: auto;
  margin: 0 auto 1.75rem;
}

.auth-card h4 {
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
  margin-bottom: .5rem;
}
.auth-card .auth-sub {
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 300;
  margin-bottom: 1.9rem;
}

/* ---- ช่องกรอก ---- */
.auth-card .form-floating > .form-control {
  font-family: 'Prompt', sans-serif;
  border-radius: 14px;
  border: 1.5px solid var(--field-border);
  background: var(--field-bg);
  min-height: 4rem;
  padding-top: 1.9rem;
  padding-bottom: .55rem;
  padding-left: 1.15rem;
  font-size: 1rem;
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.auth-card .form-floating > .form-control:focus {
  background: #fff;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(var(--brand-rgb), .13);
}
.auth-card .form-floating > label {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 300;
  padding: 1.15rem;
}
.auth-card .form-floating > .form-control:focus ~ label,
.auth-card .form-floating > .form-control:not(:placeholder-shown) ~ label {
  transform: scale(.8) translateY(-.7rem) translateX(.16rem);
  opacity: 1;
}
.auth-card .form-floating > .form-control:focus ~ label { color: var(--brand); }
/* Bootstrap วางพื้นหลังทึบสีขาวไว้หลัง label ตอนลอยขึ้นเพื่อคลุมเส้นขอบ input
   แต่ช่องแบบ "filled" ของเราไม่มีเส้นตรงนั้น พื้นขาวจึงกลายเป็นแถบแปลก ๆ บนพื้นสีเทา */
.auth-card .form-floating > .form-control:focus ~ label::after,
.auth-card .form-floating > .form-control:not(:placeholder-shown) ~ label::after {
  background-color: transparent;
}

/* ปุ่มดูรหัสผ่าน — ลอยทับมุมขวาของช่อง ไม่ใช้ input-group เพราะจะทับ label ที่ลอยขึ้น */
.auth-field { position: relative; }
.auth-field__toggle {
  position: absolute;
  top: 50%;
  right: .7rem;
  transform: translateY(-50%);
  z-index: 5;
  width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.15rem;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.auth-field__toggle:hover { color: var(--brand); background: rgba(var(--brand-rgb), .08); }
/* เว้นที่ให้ปุ่ม ไม่ให้ข้อความรหัสผ่านวิ่งไปชน */
.auth-field .form-control { padding-right: 3.4rem; }

.auth-card .link {
  color: var(--brand);
  font-weight: 400;
  text-decoration: none;
  font-size: .9rem;
}
.auth-card .link:hover { text-decoration: underline; }

/* ---- ปุ่มหลัก ---- */
.auth-card .btn-primary {
  font-family: 'Prompt', sans-serif;
  border: none;
  border-radius: 13px;
  padding: .95rem 1.5rem;
  font-weight: 500;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #14448f 0%, #1a4d95 100%);
  box-shadow: 0 12px 24px -12px rgba(var(--brand-rgb), .75);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.auth-card .btn-primary:hover:not(:disabled),
.auth-card .btn-primary:focus:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px -12px rgba(var(--brand-rgb), .85);
  filter: brightness(1.08);
}
.auth-card .btn-primary:active { transform: translateY(0); }
.auth-card .btn-primary:disabled { opacity: .55; box-shadow: none; }

/* ---- ลิงก์กลับหน้าเข้าสู่ระบบ ---- */
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-top: 1.35rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 300;
  text-decoration: none;
  transition: color .15s ease;
}
.auth-back:hover { color: var(--brand); }

/* ========== หน้าที่แสดงผลลัพธ์แทนฟอร์ม (ส่งเมลแล้ว / ลิงก์หมดอายุ) ========== */
.auth-state { text-align: center; }
.auth-state__ico {
  width: 76px; height: 76px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2.15rem;
}
.auth-state__ico--ok  { background: #e7f7ee; color: #16a34a; }
.auth-state__ico--bad { background: #fdecec; color: #dc3545; }

/* กล่องแสดงอีเมลปลายทาง — ผู้ใช้ต้องเห็นชัดว่าส่งไปที่อยู่ไหน จะได้รู้ว่าพิมพ์ผิดหรือเปล่า */
.auth-email-pill {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  max-width: 100%;
  margin-bottom: 1.1rem;
  padding: .7rem 1.05rem;
  border-radius: 12px;
  background: #eef4ff;
  border: 1px solid #dbe6fb;
  color: var(--brand);
  font-size: .92rem;
  font-weight: 500;
  word-break: break-all;
}
.auth-email-pill i { color: #6d94c6; flex-shrink: 0; }

/* แถวขอส่งอีเมลซ้ำ พร้อมตัวนับ cooldown */
.auth-resend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  font-size: .88rem;
  font-weight: 300;
  color: var(--muted);
}
.auth-resend button {
  padding: 0;
  border: none;
  background: none;
  color: var(--brand);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}
.auth-resend button:disabled {
  color: #9aa7b8;
  text-decoration: none;
  cursor: default;
}
.auth-resend button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---- แถวช่วยเหลือ + ท้ายฟอร์ม ---- */
.auth-help {
  margin-top: 1.6rem;
  text-align: center;
  font-size: .92rem;
  font-weight: 300;
  color: var(--muted);
}
.auth-help i { margin-right: .4rem; }
.auth-help a {
  color: var(--brand);
  font-weight: 400;
  text-decoration: none;
}
.auth-help a:hover { text-decoration: underline; }

.auth-foot {
  margin-top: 1.6rem;
  text-align: center;
  color: #9aa8ba;
  font-size: .82rem;
  font-weight: 300;
}

/* ========== แผงแจ้งสถานะการล็อกอิน (กรอกผิด / ถูกล็อกชั่วคราว) ==========
   ใช้แทน toast เพราะผู้ใช้ต้องเห็นจำนวนครั้งที่เหลือค้างไว้ตอนพิมพ์รหัสผ่านใหม่ */
.auth-alert {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  margin-bottom: 1.15rem;
  padding: .85rem .95rem;
  border-radius: 14px;
  border: 1px solid;
  font-size: .875rem;
  text-align: left;
  animation: auth-alert-in .28s cubic-bezier(.16, 1, .3, 1);
}
@keyframes auth-alert-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

.auth-alert--warn { background: #fff8ed; border-color: #fadfb4; color: #8a5300; }
.auth-alert--lock { background: #fdf2f2; border-color: #f7cccc; color: #9b2c2c; }
.auth-alert--info { background: #f0f7ff; border-color: #c3ddf7; color: #1a4d95; }
.auth-alert--ok   { background: #f0faf4; border-color: #bfe6cd; color: #1c6b41; }

.auth-alert__ico {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: rgba(255, 255, 255, .7);
}
.auth-alert__body { min-width: 0; }
.auth-alert__body strong { font-weight: 600; }
.auth-alert__sub {
  margin-top: .15rem;
  font-size: .82rem;
  opacity: .9;
}

/* จุดบอกจำนวนครั้งที่เหลือ — อ่านเร็วกว่าตัวเลขอย่างเดียวเวลาเหลือน้อย */
.auth-alert__pips {
  display: flex;
  gap: .3rem;
  margin-top: .5rem;
}
.auth-alert__pips span {
  width: 26px;
  height: 5px;
  border-radius: 99px;
  background: currentColor;
}
.auth-alert__pips .is-used { opacity: .18; }
.auth-alert__pips .is-left { opacity: .85; }

/* แถบเวลาที่เดินหน้าไปเรื่อย ๆ ระหว่างถูกล็อก */
.auth-alert__bar {
  margin-top: .55rem;
  height: 5px;
  border-radius: 99px;
  background: rgba(155, 44, 44, .15);
  /* ให้รางแถบเปลี่ยนสีตามสถานะเอง (แดง → เขียวตอนครบเวลา) เบราว์เซอร์เก่าใช้ค่าด้านบนแทน */
  background: color-mix(in srgb, currentColor 15%, transparent);
  overflow: hidden;
}
.auth-alert__bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: currentColor;
  opacity: .75;
  transition: width 1s linear;
}
.auth-alert__timer { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ครบเวลาแล้ว — เปลี่ยนเป็นโทนเขียวเพื่อบอกว่ากดได้แล้วโดยไม่ต้องรีเฟรช */
.auth-alert.is-ready {
  background: #f0faf4;
  border-color: #bfe6cd;
  color: #1c6b41;
}

/* ================= responsive ================= */
@media (max-width: 1199.98px) {
  .auth-brand { padding: 2.75rem 2.5rem; }
  .auth-brand__hero h1 { font-size: 2rem; }
  .auth-features { gap: 1.05rem; }
  .auth-features__ico { width: 46px; height: 46px; font-size: 1.2rem; }
}

@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form-side { min-height: 100vh; min-height: 100dvh; }
  .auth-card__logo { width: 168px; }
}

/* เคารพผู้ใช้ที่ปิดอนิเมชัน */
@media (prefers-reduced-motion: reduce) {
  .auth-card .btn-primary,
  .auth-card .form-floating > .form-control,
  .auth-field__toggle {
    transition: none;
  }
  .auth-alert { animation: none; }
  .auth-alert__bar > span { transition: none; }
}
