/* ============================================================================
 *  login.css — หน้า /login ธีมเดียวกับหน้าแรก (25 ต.ค. 2026)
 * ----------------------------------------------------------------------------
 *  ขาว–ดำ–ทอง · ฟอนต์ Sarabun + Noto Sans Thai (css/fonts.css) · ปุ่มแคปซูลดำ · แสงทองลอยด้านหลัง
 *  (ชุดเดียวกับ landing/css/landing.css + home.css — แต่ไม่ได้โหลดไฟล์นั้น
 *   เพราะหน้านี้อยู่ฝั่งแอป frontend/ และต้องเบาที่สุด: CSS ล้วน ไม่เพิ่มสคริปต์สักบรรทัด)
 *
 *  ⚠️ ใช้กับหน้า /login เท่านั้น (โหลดจาก src/pages/head-login.html)
 *     แอป (/app) และหน้าเลือกบริษัท (/companies) ใช้ธีมเดียวกันแล้ว (26 ต.ค. 2026)
 *  ⚠️ ตัวแปรขึ้นต้น --lg- ทั้งหมด — app.css มี --ink/--gold ชื่อเดียวกันอยู่ ห้ามทับ
 *
 *  🔗 ของที่สคริปต์ js/03-firebase-auth.js แตะ (ห้ามพัง)
 *     · ปุ่มแท็บ #login-tab-btn / #signup-tab-btn — สคริปต์เขียน className ทับทั้งก้อน
 *       เป็นคลาส Tailwind ⇒ ที่นี่จับ "แท็บที่เลือก" จากคลาส .bg-white ที่สคริปต์ใส่ให้
 *     · .hidden ถูกสลับบนกล่องแจ้งเตือน · ช่องยืนยันรหัส · ลูกทุกตัวของการ์ด (ด่านยืนยันอีเมล)
 *       ⇒ ห้ามตั้ง display ให้ของพวกนี้ (กับดัก .hidden แพ้ specificity) + มีกฎกันพลาดท้ายไฟล์
 *     · ด่านยืนยันอีเมลสร้างปุ่ม .gold-grad เอง ⇒ ทาสีใหม่ในการ์ดด้วย .lg-card button.gold-grad
 * ========================================================================== */

:root {
  --lg-ink:        #1D1D1F;
  --lg-ink-soft:   #515154;
  --lg-muted:      #6E6E73;
  --lg-gold:       #B08D4F;
  --lg-gold-light: #CDB386;
  --lg-gold-dark:  #86652F;
  --lg-gold-soft:  #F8F4EC;
  --lg-line:       #E8E8EA;
  --lg-alt:        #F7F7F8;
  --lg-font: 'Cleantax Text', sans-serif;
}

body.login-page {
  margin: 0; min-height: 100vh; background: #FFFFFF;
  font-family: var(--lg-font); font-weight: 400; color: var(--lg-ink-soft);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

/* 6 พ.ย. 2026 น้ำหนักตัวอักษรพื้นฐาน: เนื้อหา 400 · หัวข้อ h1–h3 600 · ปุ่ม/ป้าย 500
   เขียนแบบ body h1 ให้ชนะ preflight ของ Tailwind แต่แพ้คลาสที่ตั้งน้ำหนักไว้เอง ⇒ ดีไซน์เดิมไม่เปลี่ยน */
body.login-page h1, body.login-page h2, body.login-page h3 { font-weight: 600; }
body.login-page button, body.login-page label { font-weight: 500; }
body.login-page button, body.login-page input, body.login-page textarea, body.login-page select { font-family: inherit; }

/* ================================================================ ฉากหลัง */
.lg { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; isolation: isolate; }
.lg-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.lg-bg .orb { position: absolute; border-radius: 50%; }
.lg-bg .orb-a {
  width: 760px; height: 760px; right: -220px; top: -300px;
  background: radial-gradient(circle, rgba(205,179,134,.36), rgba(205,179,134,.10) 45%, transparent 68%);
  animation: lgDrift 16s ease-in-out infinite alternate;
}
.lg-bg .orb-b {
  width: 620px; height: 620px; left: -220px; bottom: -320px;
  background: radial-gradient(circle, rgba(176,141,79,.20), transparent 66%);
  animation: lgDrift2 20s ease-in-out infinite alternate;
}
@keyframes lgDrift  { to { transform: translate(-90px, 80px) scale(1.12); } }
@keyframes lgDrift2 { to { transform: translate(110px, -70px) scale(.92); } }
.lg-bg .dots {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(17,17,17,.09) 1px, transparent 1.3px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 55% 60% at 50% 45%, #000 10%, transparent 70%);
          mask-image: radial-gradient(ellipse 55% 60% at 50% 45%, #000 10%, transparent 70%);
}

/* ================================================================ แถบบน */
.lg-top { display: flex; align-items: center; justify-content: space-between; padding: 20px clamp(20px, 4vw, 40px); }
.lg-back {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem 1rem .5rem .8rem;
  border: 1px solid var(--lg-line); border-radius: 999px; background: rgba(255,255,255,.75);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: .875rem; font-weight: 500; color: var(--lg-ink); text-decoration: none;
  transition: border-color .2s ease, transform .2s ease;
}
.lg-back:hover { border-color: var(--lg-ink); }
.lg-back svg { transition: transform .2s ease; }
.lg-back:hover svg { transform: translateX(-3px); }
.lg-help { font-size: .875rem; color: var(--lg-muted); }
.lg-help a { color: var(--lg-ink); font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.lg-help a:hover { color: var(--lg-gold-dark); }

/* ================================================================ กลางจอ */
.lg-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px 16px 48px; }
.lg-wrap { width: 100%; max-width: 420px; }

.lg-head { text-align: center; margin-bottom: 1.8rem; }
.lg-logo { display: inline-block; }
.lg-logo img { height: 64px; width: auto; margin: 0 auto 1.4rem; object-fit: contain; }
.lg-badge {
  display: inline-flex; align-items: center; gap: .55rem; margin-bottom: 1rem;
  padding: .32rem .9rem .32rem .7rem; border: 1px solid var(--lg-line); border-radius: 999px;
  background: rgba(255,255,255,.8); font-size: .8rem; font-weight: 500; color: var(--lg-ink-soft);
}
.lg-badge i { width: 7px; height: 7px; border-radius: 999px; background: var(--lg-gold); box-shadow: 0 0 0 4px rgba(176,141,79,.16); }
.lg-title { margin: 0; font-size: clamp(2rem, 5vw, 2.5rem); line-height: 1.25; font-weight: 600; letter-spacing: -.02em; color: var(--lg-ink); }
.lg-sub { margin: .6rem 0 0; font-size: 1rem; color: var(--lg-muted); }
.lg-sub b { font-weight: 600; color: var(--lg-ink); }

/* การ์ดฟอร์ม — ขอบทองวิ่งรอบช้าๆ (เบราว์เซอร์ที่ไม่รู้จัก @property = ขอบเทานิ่ง) */
@property --lg-ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.lg-card {
  position: relative; padding: clamp(1.5rem, 5vw, 2rem); border-radius: 24px;
  border: 1px solid transparent;
  background:
    linear-gradient(#FFFFFF, #FFFFFF) padding-box,
    conic-gradient(from var(--lg-ang), var(--lg-line) 0deg, var(--lg-line) 220deg, var(--lg-gold-light) 275deg, #FFF1D2 292deg, var(--lg-gold-light) 310deg, var(--lg-line) 360deg) border-box;
  box-shadow: 0 50px 100px -50px rgba(17,17,17,.28), 0 12px 30px -18px rgba(17,17,17,.10);
  animation: lgSpin 8s linear infinite;
}
@keyframes lgSpin { to { --lg-ang: 360deg; } }

/* แท็บ เข้าสู่ระบบ / สมัครสมาชิก — แท็บที่เลือกคือปุ่มที่สคริปต์ใส่ .bg-white */
.lg-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 1.4rem; border-radius: 999px; background: #F2F2F4; }
.lg-tabs > button {
  flex: 1; padding: .6rem .5rem; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; box-shadow: none;
  font-family: inherit; font-size: .925rem; font-weight: 500; color: var(--lg-muted);
  transition: background .25s ease, color .25s ease, box-shadow .25s ease;
}
.lg-tabs > button:hover { color: var(--lg-ink); }
.lg-tabs > button.bg-white { background: #FFFFFF; color: var(--lg-ink); box-shadow: 0 6px 16px -8px rgba(17,17,17,.35), 0 0 0 1px rgba(17,17,17,.04); }

/* กล่องแจ้งเตือน (สคริปต์สลับ .hidden เอง — ห้ามตั้ง display) */
.lg-alert { margin-bottom: 1rem; padding: .75rem .95rem; border-radius: 14px; font-size: .85rem; font-weight: 500; line-height: 1.55; }
.lg-alert.is-error { background: #FFF1F2; border: 1px solid #FECDD3; color: #BE123C; }
.lg-alert.is-info  { background: #ECFDF5; border: 1px solid #A7F3D0; color: #047857; }

/* ช่องกรอก */
.lg-form > * + * { margin-top: 1.05rem; }
.lg-label-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .45rem; }
.lg-label { display: block; margin-bottom: .45rem; font-size: .85rem; font-weight: 500; color: var(--lg-ink); }
.lg-label-row .lg-label { margin-bottom: 0; }
.lg-link-btn { padding: 0; border: 0; background: none; cursor: pointer; font-family: inherit; font-size: .825rem; font-weight: 500; color: var(--lg-gold-dark); }
.lg-link-btn:hover { color: var(--lg-ink); text-decoration: underline; text-underline-offset: 3px; }
.lg-input-wrap { position: relative; }
.lg-input {
  width: 100%; box-sizing: border-box; height: 50px; padding: 0 1rem;
  border: 1px solid var(--lg-line); border-radius: 14px; background: var(--lg-alt); outline: none;
  font-family: inherit; font-size: 1rem; font-weight: 500; color: var(--lg-ink);
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.lg-input::placeholder { color: #AEAEB2; font-weight: 400; }
.lg-input:hover { border-color: #D2D2D7; }
.lg-input:focus { background: #FFFFFF; border-color: var(--lg-gold); box-shadow: 0 0 0 4px rgba(176,141,79,.16); }
.lg-input.has-eye { padding-right: 3rem; }
/* Chrome เติมอีเมล/รหัสอัตโนมัติแล้วทาพื้นฟ้า — ให้กลืนกับช่องปกติ */
.lg-input:-webkit-autofill,
.lg-input:-webkit-autofill:hover,
.lg-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--lg-ink);
  -webkit-box-shadow: 0 0 0 40px #F7F7F8 inset;
  caret-color: var(--lg-ink);
  transition: background-color 9999s ease 0s;
}
.lg-eye {
  position: absolute; top: 0; right: 0; bottom: 0; width: 48px; border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: #AEAEB2; transition: color .2s ease;
}
.lg-eye:hover { color: var(--lg-ink); }

/* ปุ่มหลัก — ดำแคปซูล + ประกายวิ่งผ่านตอนชี้ (แบบหน้าแรก) */
.lg-submit, .lg-card button.gold-grad {
  position: relative; overflow: hidden; isolation: isolate;
  width: 100%; height: 52px; margin-top: .4rem; padding: 0 1.5rem; border: 1px solid var(--lg-ink); border-radius: 999px;
  background: var(--lg-ink); color: #FFFFFF; box-shadow: 0 14px 28px -16px rgba(17,17,17,.6);
  font-family: inherit; font-size: 1rem; font-weight: 500; letter-spacing: 0; cursor: pointer;
  transition: background .2s ease, box-shadow .2s ease, transform .12s ease;
}
.lg-submit::after, .lg-card button.gold-grad::after {
  content: ''; position: absolute; inset: -2px; z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255,240,210,.32) 50%, transparent 65%);
  transform: translateX(-130%);
}
.lg-submit:hover, .lg-card button.gold-grad:hover { background: #000000; filter: none; box-shadow: 0 16px 32px -14px rgba(17,17,17,.6), 0 0 0 3px rgba(205,179,134,.28); }
.lg-submit:hover::after, .lg-card button.gold-grad:hover::after { transform: translateX(130%); transition: transform .8s cubic-bezier(.2,.7,.2,1); }
.lg-submit:active, .lg-card button.gold-grad:active { transform: translateY(1px) scale(.99); }
.lg-submit:disabled { opacity: .7; cursor: progress; }

/* ปุ่มหลักในด่านยืนยันอีเมล — app.css ใส่ .gold-grad แบบ !important (ครีมทอง) ต้องสู้ด้วย !important
   (จำกัดแค่ในการ์ดหน้านี้ — ปุ่ม .gold-grad ในแอปไม่โดน เพราะ login.css โหลดเฉพาะ /login) */
.lg-card button.gold-grad {
  background: var(--lg-ink) !important; color: #FFFFFF !important;
  border: 1px solid var(--lg-ink) !important; font-weight: 500 !important;
  box-shadow: 0 14px 28px -16px rgba(17,17,17,.6) !important;
}
.lg-card button.gold-grad:hover {
  background: #000000 !important; border-color: #000000 !important; color: #FFFFFF !important;
  box-shadow: 0 16px 32px -14px rgba(17,17,17,.6), 0 0 0 3px rgba(205,179,134,.28) !important;
}
.lg-card button.gold-grad:active { box-shadow: none !important; }
#verify-gate { display: grid; gap: .8rem; }
#verify-gate > * { margin-top: 0; }   /* สคริปต์ใส่ space-y-3 มาด้วย — ใช้ gap อย่างเดียว ไม่งั้นระยะซ้อนสองเท่า */
#verify-gate > p:first-child { margin: 0; font-size: 1.15rem; font-weight: 600; color: var(--lg-ink); }
#verify-gate > p { margin: 0; font-size: .925rem; line-height: 1.7; color: var(--lg-ink-soft); }
#verify-gate > button.gold-grad { margin-top: .4rem; }
/* ช่องกรอกรหัส 6 หลัก — ช่องเดียว ใช้วางรหัสจากเมลได้ และมือถือเติมรหัสให้เองได้ (one-time-code) */
#verify-code {
  width: 100%; box-sizing: border-box; height: 60px; padding: 0 0 0 .5em; text-align: center;
  border: 1px solid #D2D2D7; border-radius: 16px; background: #F7F7F8; color: var(--lg-ink);
  font-family: inherit; font-size: 1.7rem; font-weight: 600; letter-spacing: .5em; font-variant-numeric: tabular-nums;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
#verify-code::placeholder { color: #C7C7CC; }
#verify-code:focus { outline: none; background: #FFFFFF; border-color: var(--lg-gold, #B08D4F); box-shadow: 0 0 0 4px rgba(176,141,79,.16); }
.lg-card #verify-gate button:disabled { opacity: .55; cursor: default; }

/* ปุ่มรองในด่านยืนยันอีเมล (สคริปต์สร้างเอง) */
.lg-card #verify-gate button:not(.gold-grad) {
  width: 100%; height: 46px; border: 1px solid #D2D2D7; border-radius: 999px; background: #FFFFFF;
  font-family: inherit; font-size: .925rem; font-weight: 500; color: var(--lg-ink); cursor: pointer;
}
.lg-card #verify-gate button:not(.gold-grad):hover { border-color: var(--lg-ink); background: #FFFFFF; }

/* ลิงก์ข้อตกลง / นโยบาย (จุดยอมรับข้อตกลงฯ ข้อ 01 — ห้ามเอาออก) */
.lg-check { display: flex; align-items: flex-start; gap: .6rem; font-size: .875rem; line-height: 1.6; color: var(--lg-ink-soft); cursor: pointer; }
.lg-check input { flex: none; width: 1.05rem; height: 1.05rem; margin-top: .17rem; accent-color: var(--lg-ink); cursor: pointer; }
.lg-check a { color: var(--lg-ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--lg-gold-light); text-underline-offset: 3px; }
.lg-legal { margin: 1.4rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--lg-line); text-align: center; font-size: .825rem; line-height: 1.9; color: var(--lg-muted); }
.lg-legal a { color: var(--lg-ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--lg-gold-light); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.lg-legal a:hover { color: var(--lg-gold-dark); }

/* จุดเด่นความปลอดภัย 3 ข้อใต้การ์ด (ข้อความตรงกับ FAQ หน้าแรก ข้อ "ข้อมูลเก็บไว้ที่ไหน") */
.lg-trust { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.2rem; margin: 1.6rem 0 0; padding: 0; list-style: none; }
.lg-trust li { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--lg-muted); }
.lg-trust svg { color: var(--lg-gold); flex: none; }
.lg-copy { margin: 1.4rem 0 0; text-align: center; font-size: .78rem; color: #AEAEB2; }

/* ================================================================ โผล่ตอนเปิดหน้า */
/* รอจนจอ "กำลังตรวจสอบสิทธิ์" ถูกถอดออก (hideBootGate) แล้วค่อยเล่น — CSS ล้วน ไม่ต้องมีสคริปต์
   (เบราว์เซอร์เก่าที่ไม่รู้จัก :has() = เล่นทันทีใต้จอโหลด ก็ไม่เสียหาย) */
.lg-wrap > *, .lg-top { animation: lgUp .8s cubic-bezier(.2,.75,.15,1) both; }
.lg-top { animation-delay: .35s; }
.lg-wrap > :nth-child(2) { animation-delay: .1s; }
.lg-wrap > :nth-child(3) { animation-delay: .2s; }
.lg-wrap > :nth-child(4) { animation-delay: .28s; }
/* การ์ดมีขอบทองหมุนอยู่แล้ว — ต้องใส่ทั้งสองแอนิเมชันในกฎเดียว ไม่งั้นอันหลังทับอันแรก */
.lg-wrap > .lg-card { animation: lgUp .8s cubic-bezier(.2,.75,.15,1) .1s both, lgSpin 8s linear infinite; }
body.login-page:has(#boot-gate) .lg-wrap > *,
body.login-page:has(#boot-gate) .lg-top { animation-play-state: paused; }
@keyframes lgUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ================================================================ จอแคบ */
@media (max-width: 560px) {
  .lg-top { padding: 14px 16px; }
  .lg-help { display: none; }
  .lg-logo img { height: 54px; margin-bottom: 1.1rem; }
  .lg-card { border-radius: 20px; }
}

/* ลดการเคลื่อนไหว: ไม่มีอะไรขยับ */
@media (prefers-reduced-motion: reduce) {
  .lg-bg .orb, .lg-card, .lg-wrap > *, .lg-top { animation: none !important; }
}

/* กันพลาด: ไม่ว่ากฎข้างบนจะตั้ง display อะไร .hidden ในหน้านี้ต้องซ่อนจริง */
#login-screen .hidden { display: none !important; }

/* 🔤 ตัวมีสี = Noto Sans Thai (6 พ.ย. 2026) — ตัวปกติ Sarabun · ตัวหนา/มีสี Noto (ดู css/fonts.css และหมวดเดียวกันท้าย app.css)
   ไม่ใส่สถานะ :hover — ฟอนต์สองตัวกว้างไม่เท่ากัน ชี้เมาส์แล้วตัวหนังสือจะกระตุก */
.lg-alert.is-error, .lg-alert.is-info, .lg-link-btn { font-family: 'Cleantax Accent', sans-serif; }
