/* ================================================================
   task_management_v2 — auth.css
   ----------------------------------------------------------------
   สไตล์เฉพาะหน้า auth (login / forgot / reset) แบบ split-screen 2026
   โหลดเฉพาะใน layouts/auth.php เท่านั้น จึงไม่กระทบ style.css กลาง
   (style.css กลางถูกจำกัดให้ใช้เฉพาะ token ของ Cuba — ห้ามเพิ่ม token เอง)

   ชุดสีน้ำเงินอ้างอิงจากแบรนด์ tdh_portal (my-tdh.com):
     --tdh-dark-blue #1a4d95 (แกนหลัก) · --tdh-blue #2563b0
     --tdh-primary #0d47a1 · --tdh-accent #1976d2 · --tdh-light-blue #5cb8e4
   token ที่นิยามเพิ่มถูก scope ไว้ใต้ .auth-shell เท่านั้น
   ================================================================ */

.auth-shell {
  /* แกนสีน้ำเงินจากแบรนด์ TDH */
  --brand: #1a4d95;
  --brand-600: #0d3266;
  --brand-400: #2563b0;
  --brand-rgb: 26, 77, 149;
  --ink: #1c1c28;
  --muted: #6b7280;
  --field-bg: #f6f8fb;
  --field-border: #e2e8f0;
  --card-radius: 22px;

  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: #fff;
  overflow: hidden;
}

/* ---------- ฝั่งซ้าย: brand panel ---------- */
.auth-brand {
  position: relative;
  overflow: hidden;
  padding: clamp(2.5rem, 5vw, 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(120% 120% at 0% 0%, #2f6fc0 0%, transparent 45%),
    radial-gradient(120% 120% at 100% 100%, #1565c0 0%, transparent 55%),
    linear-gradient(135deg, var(--brand) 0%, #123e7d 55%, var(--brand-600) 100%);
}

/* blobs เบลอ ๆ ให้ดูมีมิติ */
.auth-brand::before,
.auth-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .5;
  pointer-events: none;
}
.auth-brand::before {
  width: 420px; height: 420px;
  top: -120px; right: -120px;
  background: #5cb8e4;
}
.auth-brand::after {
  width: 340px; height: 340px;
  bottom: -110px; left: -80px;
  background: #2f6fc0;
}

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

.auth-brand__logo {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .2px;
}
/* โลโก้ที่แอดมินอัปโหลด — บนแผงแบรนด์ (พื้นน้ำเงินเข้ม) */
.auth-brand__logo .auth-brand__img {
  max-height: 48px;
  max-width: 220px;
  width: auto;
  object-fit: contain;
}
.auth-brand__logo .auth-brand__mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  backdrop-filter: blur(6px);
  font-size: 1.35rem;
}

.auth-brand__hero { max-width: 30ch; }
.auth-brand__hero h1 {
  font-size: clamp(1.9rem, 3.2vw, 2.7rem);
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 1rem;
}
.auth-brand__hero p {
  font-size: 1.02rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, .82);
  margin: 0;
}

.auth-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.auth-features li {
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: .96rem;
  color: rgba(255, 255, 255, .92);
}
.auth-features .auth-features__ico {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 1.2rem;
}

.auth-brand__foot {
  font-size: .82rem;
  color: rgba(255, 255, 255, .6);
}

/* ---------- ฝั่งขวา: ฟอร์ม ---------- */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  background:
    radial-gradient(80% 60% at 50% 0%, #eaf1fb 0%, transparent 60%),
    #ffffff;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

/* โลโก้เล็กบนมือถือ (ซ่อนบนจอใหญ่ เพราะมี brand panel แล้ว) */
.auth-card__brand {
  display: none;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 2rem;
}
.auth-card__brand i { color: var(--brand); font-size: 1.6rem; }
.auth-card__brand .auth-card__img { max-height: 46px; max-width: 220px; width: auto; object-fit: contain; }

/* หัวข้อฟอร์มจากวิว (.theme-form > h4 + p) */
.auth-card .theme-form h4 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: .35rem;
}
.auth-card .theme-form > p {
  color: var(--muted);
  margin-bottom: 1.75rem;
}

/* ช่องกรอก — โมเดิร์น นุ่ม โฟกัสมีเรืองแสง */
.auth-card .form-floating > .form-control {
  border-radius: 14px;
  border: 1.5px solid var(--field-border);
  background: var(--field-bg);
  min-height: 3.65rem;
  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), .15);
}
.auth-card .form-floating > label {
  color: var(--muted);
  padding-left: 1rem;
}
.auth-card .form-floating > .form-control:focus ~ label {
  color: var(--brand);
}
/* Bootstrap วางพื้นหลังทึบ (สีขาว = --bs-body-bg) ไว้หลัง 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;
}

/* ปุ่มหลัก — gradient + ยกเงาตอน hover */
.auth-card .btn-primary {
  border: none;
  border-radius: 14px;
  padding: .85rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-400) 100%);
  box-shadow: 0 10px 22px -8px rgba(var(--brand-rgb), .55);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.auth-card .btn-primary:hover,
.auth-card .btn-primary:focus {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -8px rgba(var(--brand-rgb), .65);
  filter: brightness(1.05);
}
.auth-card .btn-primary:active { transform: translateY(0); }

/* ตัวคั่น "หรือ" */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-size: .85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--field-border);
}

/* ปุ่ม SSO — outline โมเดิร์น */
.auth-card .btn-outline-secondary {
  border-radius: 14px;
  padding: .8rem 1.5rem;
  font-weight: 600;
  border: 1.5px solid var(--field-border);
  color: var(--ink);
  background: #fff;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.auth-card .btn-outline-secondary:hover {
  border-color: var(--brand-400);
  background: #f4f8fd;
  color: var(--ink);
  transform: translateY(-1px);
}

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

/* ---------- แผงแจ้งสถานะการล็อกอิน (กรอกผิด / ถูกล็อกชั่วคราว) ----------
   ใช้แทน 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;
  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__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;
}

/* กล่องหมายเหตุใต้ฟอร์ม — ตอนนี้ยังไม่มีหน้าไหนใช้ (กล่องบอกรหัสผ่านทดสอบถูกถอดออกก่อนขึ้น
   production แล้ว) เก็บสไตล์ไว้เผื่อต้องแสดงหมายเหตุอื่นในหน้า auth ภายหลัง */
.auth-note {
  margin-top: 1.75rem;
  padding: .7rem .9rem;
  border-radius: 12px;
  background: #f6f8fb;
  border: 1px dashed var(--field-border);
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}
.auth-note code {
  background: rgba(var(--brand-rgb), .1);
  color: var(--brand);
  padding: .1rem .4rem;
  border-radius: 6px;
}

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-card__brand { display: inline-flex; }
  .auth-form-side { min-height: 100vh; min-height: 100dvh; }
}

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