/* หน้าเข้าสู่ระบบ — กล่องขนาด 1058x726 วางกลางจอ */
:root {
  --lg-w: 1058px;
  --lg-h: 726px;
  --lg-hero-w: 613px;
  --lg-blue: #1d5fd6;
  --lg-blue-2: #0b46b8;
  --lg-navy: #0d2f6e;
  --lg-ink: #1d2a4d;
  --lg-muted: #6a7799;
}
.page-login { background: #dde9fb; font-family: 'Sarabun', system-ui, sans-serif; }
.page-login .content-plain { max-width: none; padding: 0; }
.page-login .content-plain > .alert { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 20; min-width: 300px; }

/* เวที: พื้นหลังเต็มจอ */
.lg-stage { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; overflow: hidden; background: #dde9fb; }

/* กล่องหลัก */
.lg-shell { position: relative; z-index: 1; width: var(--lg-w); height: var(--lg-h); display: grid; grid-template-columns: var(--lg-hero-w) 1fr;
  border-radius: 24px; overflow: hidden; background: #8cc0f5;
  box-shadow: 0 40px 80px -30px rgba(13,47,110,.65), 0 0 0 1px rgba(255,255,255,.5); }
.lg-shell::before { content: ''; position: absolute; inset: -30px; background: url('../img/login-hero.jpg') right center / cover no-repeat; filter: blur(14px) saturate(1.15); z-index: 0; }
.lg-shell::after { content: ''; position: absolute; inset: 0; z-index: 0; background: linear-gradient(180deg, rgba(220,236,255,.35), rgba(29,95,214,.25)); }

/* แสงเกรเดียนขาววิ่งผ่านเป็นระยะ (วิ่ง ~1.6 วิ แล้วพักจนครบรอบ 7 วิ) — อยู่บนสุด ไม่รับคลิก */
.lg-shine { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; border-radius: inherit; }
.lg-shine::before { content: ''; position: absolute; top: -20%; bottom: -20%; left: 0; width: 38%;
  background: linear-gradient(100deg, transparent 0%, rgba(255,255,255,0) 20%, rgba(255,255,255,.45) 50%, rgba(255,255,255,0) 80%, transparent 100%);
  transform: translateX(-160%) skewX(-18deg); animation: lgShine 7s ease-in-out 1.2s infinite; }
@keyframes lgShine {
  0%   { transform: translateX(-160%) skewX(-18deg); }
  23%  { transform: translateX(360%) skewX(-18deg); }
  100% { transform: translateX(360%) skewX(-18deg); }
}

/* ฝั่งภาพโรงเรียน */
.lg-hero { position: relative; z-index: 1; background: url('../img/login-hero.jpg') left top / cover no-repeat;
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }

/* ดาวใสระยิบระยับ — สร้างด้วย JS สุ่มตำแหน่ง (login.php) */
.lg-sparkles { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; border-radius: inherit; }
.lg-spark { position: absolute; transform: translate(-50%, -50%) scale(0); opacity: 0;
  /* ดาว 4 แฉก + วงแสงเรืองตรงกลาง ให้เห็นชัดทั้งบนฟ้าและบนฟอร์มสีขาว */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M12 0C12.8 8.2 15.8 11.2 24 12 15.8 12.8 12.8 15.8 12 24 11.2 15.8 8.2 12.8 0 12 8.2 11.2 11.2 8.2 12 0Z'/%3E%3C/svg%3E") center / contain no-repeat,
    radial-gradient(circle, rgba(255,255,255,.9) 0, rgba(190,222,255,.55) 18%, rgba(140,195,255,0) 48%);
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 6px rgba(120,180,255,.9));
  animation: lgSpark 1.8s ease-in-out forwards; }
@keyframes lgSpark {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0) rotate(-35deg); }
  45%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.15) rotate(35deg); }
}

/* ธงชาติในภาพปลิวตามลม — กรอบครอบธง (พิกัดบนภาพที่แสดง 631x726) ชิดเสาด้านขวา */
.lg-flag { position: absolute; left: 526px; top: 92px; width: 62px; height: 98px; pointer-events: none;
  /* เฟดขอบซ้าย/บน/ล่าง ให้ท้องฟ้าในกรอบกลืนกับภาพเดิม (ขอบขวาชิดเสา ไม่ขยับ) */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5px), linear-gradient(180deg, transparent, #000 6px, #000 calc(100% - 6px), transparent);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(90deg, transparent, #000 5px), linear-gradient(180deg, transparent, #000 6px, #000 calc(100% - 6px), transparent);
  mask-composite: intersect; }
.lg-flag span { position: absolute; top: 0; bottom: 0; left: calc(var(--i) * 2px); width: 2.6px;
  background: url('../img/login-hero.jpg') no-repeat;
  background-size: 631px 726px; background-position: calc(-526px - var(--i) * 2px) -92px;
  --amp: calc(var(--d) * .16px);
  animation: lgWave 1.5s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -.055s); }
@keyframes lgWave {
  from { transform: translateY(calc(var(--amp) * -1)); }
  to   { transform: translateY(var(--amp)); }
}

/* ฝั่งฟอร์ม */
.lg-side { position: relative; z-index: 2; display: grid; place-items: center; padding: 22px 26px 22px 6px; }
.lg-side-inner { width: 100%; }
.lg-glass { width: 100%; padding: 14px 14px 8px; border-radius: 26px;
  background: rgba(255,255,255,.3); border: 1px solid rgba(255,255,255,.7);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 24px 48px -20px rgba(13,47,110,.5), inset 0 1px 0 rgba(255,255,255,.75);
  animation: lgIn .7s cubic-bezier(.2,.8,.2,1) both; }
.lg-card { position: relative; background: rgba(255,255,255,.94); border-radius: 20px; padding: 66px 22px 20px; margin-top: 46px;
  box-shadow: 0 10px 30px -12px rgba(13,47,110,.25); }
@keyframes lgIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.lg-emblem { position: absolute; top: -52px; left: 50%; transform: translateX(-50%); width: 112px; height: 112px; border-radius: 50%;
  background: #fff; display: grid; place-items: center;
  box-shadow: 0 12px 26px -10px rgba(13,47,110,.4), 0 0 0 6px rgba(255,255,255,.6); }
.lg-emblem img { width: auto; height: 82px; }
.lg-hero-emblem { position: absolute; left: 143px; top: 16px; height: 122px; width: auto; filter: drop-shadow(0 6px 10px rgba(13,47,110,.35)); }

.lg-title { font-family: 'Prompt', 'Sarabun', sans-serif; font-weight: 700; font-size: 1.85rem; color: var(--lg-navy); text-align: center; margin: 0; line-height: 1.2; }
.lg-sub { text-align: center; color: var(--lg-ink); font-size: .98rem; font-weight: 500; margin: .2rem 0 .8rem; }
.lg-quote { margin: 0 0 1rem; padding: .55rem .9rem; border-radius: 12px; text-align: center;
  background: linear-gradient(135deg, #e3efff, #d6e8ff); color: var(--lg-navy); font-family: 'Prompt', 'Sarabun', sans-serif; font-weight: 500; font-size: .98rem; line-height: 1.45; }

.lg-alert { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; margin-bottom: .7rem; border-radius: 10px;
  background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; font-size: .88rem; animation: lgShake .4s ease; }
@keyframes lgShake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

.lg-field { position: relative; margin-bottom: .65rem; }
.lg-ico { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: #5d6b8f; font-size: 1.1rem; pointer-events: none; transition: color .2s; }
.lg-input { width: 100%; height: 46px; padding: 0 2.9rem 0 2.9rem; border: 1.5px solid #dbe3f2; border-radius: 13px; background: #fff;
  font-size: .98rem; color: var(--lg-ink); box-shadow: 0 2px 6px -3px rgba(13,47,110,.15); transition: border-color .2s, box-shadow .2s; }
.lg-input::placeholder { color: #7a86a6; }
.lg-input:focus { outline: none; border-color: var(--lg-blue); box-shadow: 0 0 0 4px rgba(29,95,214,.14); }
.lg-field:focus-within .lg-ico { color: var(--lg-blue); }
.lg-eye { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: transparent; color: #5d6b8f; font-size: 1.1rem; transition: background .2s, color .2s; }
.lg-eye:hover { background: #eef3fd; color: var(--lg-blue); }

.lg-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .1rem 0 .8rem; font-size: .92rem; }
.lg-check { display: inline-flex; align-items: center; gap: .5rem; color: var(--lg-ink); cursor: pointer; user-select: none; margin: 0; }
.lg-check input { width: 18px; height: 18px; accent-color: var(--lg-blue); cursor: pointer; }
.lg-link { color: var(--lg-blue); font-weight: 600; background: none; border: 0; padding: 0; }
.lg-link:hover { color: var(--lg-blue-2); text-decoration: underline; }

.lg-btn { position: relative; width: 100%; height: 50px; border: 0; border-radius: 13px; color: #fff; font-weight: 600; font-size: 1.08rem;
  background: linear-gradient(180deg, #2b7bf0 0%, #1858d0 55%, #0b46b8 100%);
  box-shadow: 0 12px 22px -12px rgba(11,70,184,.85), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .15s, filter .2s, box-shadow .2s; }
.lg-btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.lg-btn:active { transform: none; }
.lg-btn .bi { margin-right: .5rem; }
.lg-spinner { display: none; width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: lgSpin .7s linear infinite; }
.lg-btn.is-loading .lg-btn-text { visibility: hidden; }
.lg-btn.is-loading .lg-spinner { display: block; position: absolute; left: 50%; top: 50%; margin: -11px 0 0 -11px; }
@keyframes lgSpin { to { transform: rotate(360deg); } }

.lg-divider { display: flex; align-items: center; gap: .8rem; margin: .95rem 0 .65rem; color: var(--lg-muted); font-size: .85rem; }
.lg-divider::before, .lg-divider::after { content: ''; flex: 1; height: 1px; background: #d5ddec; }
.lg-public { display: flex; align-items: center; justify-content: center; gap: .5rem; height: 44px; border-radius: 12px; background: #fff;
  border: 1.5px solid #dbe3f2; color: var(--lg-ink); font-weight: 600; font-size: .95rem; box-shadow: 0 2px 6px -3px rgba(13,47,110,.15); transition: border-color .2s, transform .2s, box-shadow .2s; }
.lg-public .bi { color: var(--lg-blue); }
.lg-public:hover { border-color: #a9c3f2; transform: translateY(-1px); box-shadow: 0 10px 20px -12px rgba(13,47,110,.4); color: var(--lg-ink); }

.lg-foot { text-align: center; margin-top: .45rem; font-size: .78rem; color: rgba(13,47,110,.8); }

/* modal ลืมรหัสผ่าน */
.lg-modal .modal-content { border: 0; border-radius: 20px; }
.lg-modal .modal-ico { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 1rem; display: grid; place-items: center; font-size: 1.8rem; background: #e3efff; color: var(--lg-blue); }

.lg-mobile-head { display: none; }

/* จอเล็กกว่ากล่อง: เปลี่ยนเป็นการ์ดเดี่ยวเต็มความกว้าง */
@media (max-width: 1090px) {
  .lg-stage { place-items: start center; padding: 20px 16px 28px; }
  .lg-shell { width: 100%; max-width: 480px; height: auto; grid-template-columns: minmax(0, 1fr); background: none; box-shadow: none; overflow: visible; border-radius: 0; }
  .lg-shell::before, .lg-shell::after, .lg-hero, .lg-shine, .lg-sparkles { display: none; }
  .lg-side { padding: 0; }
  .lg-mobile-head { display: block; text-align: center; color: var(--lg-navy); margin-bottom: .25rem; }
  .lg-glass { background: rgba(255,255,255,.55); }
  .lg-mobile-head h1 { font-family: 'Prompt', 'Sarabun', sans-serif; font-weight: 700; font-size: 1.6rem; margin: 0; }
  .lg-mobile-head p { margin: 0; font-size: .95rem; }
}
@media (prefers-reduced-motion: reduce) { .lg-glass, .lg-alert { animation: none; } .lg-shine { display: none; } .lg-flag span { animation: none; } }
