/* ==========================================
   Modals
   ========================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
}

.modal-wrapper {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem 1rem 5rem 1rem;
  text-align: center;
}

@media (min-width: 640px) {
  .modal-wrapper {
    display: block;
    padding: 0;
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}

.modal-trick {
  display: none;
}

@media (min-width: 640px) {
  .modal-trick {
    display: inline-block;
    vertical-align: middle;
    height: 100vh;
  }
}

.modal-box {
  display: inline-block;
  vertical-align: bottom;
  background-color: white;
  border-radius: 1.5rem;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(1);
  transition: all 0.3s;
  border: 1px solid var(--slate-100);
  position: relative;
  width: 100%;
}

@media (min-width: 640px) {
  .modal-box {
    margin: 2rem 0;
    vertical-align: middle;
  }
}

.auth-box {
  max-width: 28rem;
}

.news-box {
  max-width: 42rem;
}

.modal-box-lg {
  max-width: 58rem;
}

.confirm-box {
  max-width: 24rem;
}

.confirm-icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background-color: var(--rose-50);
  color: var(--rose-600);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-icon svg {
  width: 1.75rem;
  height: 1.75rem;
}

.confirm-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--slate-900);
  text-align: center;
  margin: 0 0 0.5rem;
}

.confirm-message {
  font-size: 0.85rem;
  color: var(--slate-500);
  text-align: center;
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
}

.confirm-cancel-btn,
.confirm-ok-btn {
  flex: 1;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 0.75rem;
  cursor: pointer;
  border: none;
  transition: filter 0.15s ease, background-color 0.15s ease;
}

.confirm-cancel-btn {
  border: 1px solid var(--slate-200);
  background-color: white;
  color: var(--slate-600);
}

.confirm-cancel-btn:hover {
  background-color: var(--slate-100);
}

.confirm-ok-btn {
  background-color: var(--rose-600);
  color: white;
}

.confirm-ok-btn:hover {
  filter: brightness(1.08);
}

.modal-close-btn {
  position: absolute;
  right: 1rem;
  top: 1rem;
}

.modal-close-btn button {
  color: var(--slate-400);
  background: transparent;
  border: none;
  padding: 0.25rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close-btn button:hover {
  color: var(--slate-600);
  background-color: var(--slate-100);
}

.modal-content {
  background-color: white;
  padding: 2rem 1.5rem;
}

.auth-modal-logo {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  display: block;
}

@media (min-width: 640px) {
  .modal-content {
    padding: 2rem;
  }
}

.modal-content-wide {
  padding: 1.5rem;
}

@media (min-width: 640px) {
  .modal-content-wide {
    padding: 2rem;
  }
}

.auth-tabs {
  display: flex;
  gap: 0.25rem;
  background-color: var(--slate-100);
  border-radius: 9999px;
  padding: 0.3rem;
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: var(--slate-500);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.auth-tab:hover {
  color: var(--slate-700);
}

.auth-tab.active {
  font-weight: 700;
  background-color: white;
  color: var(--brand-600);
  box-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.15), 0 1px 2px -1px rgba(15, 23, 42, 0.15);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--slate-900);
  background-color: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: 0.75rem;
  font-family: inherit;
  box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.form-input::placeholder {
  color: var(--slate-400);
}

.form-input:hover {
  border-color: var(--slate-300);
}

.form-input:focus {
  outline: none;
  background-color: white;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(255, 114, 32, 0.12);
}

.password-field-wrap {
  position: relative;
}

.password-field-wrap .form-input {
  padding-right: 2.75rem;
}

.password-toggle-btn {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 0.3rem;
  color: var(--slate-400);
  cursor: pointer;
  display: flex;
  border-radius: 0.4rem;
  transition: color 0.15s ease;
}

.password-toggle-btn:hover {
  color: var(--slate-600);
}

.password-toggle-btn .eye-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.forgot-pwd {
  font-size: 0.75rem;
  color: var(--brand-600);
  cursor: pointer;
}

.forgot-pwd:hover {
  text-decoration: underline;
}

/* ==========================================
   OTP: กล่องกรอกรหัสทีละหลัก + ไอคอน
   ========================================== */
.otp-icon-circle {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--indigo-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 10px 20px -5px rgba(255, 114, 32, 0.35);
}

.otp-icon-circle svg {
  width: 2rem;
  height: 2rem;
}

.otp-input-group {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.25rem 0 1.25rem;
}

.otp-digit {
  width: 2.75rem;
  height: 3.25rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  border: 2px solid var(--slate-200);
  border-radius: 0.75rem;
  color: var(--slate-900);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.otp-digit:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(255, 114, 32, 0.15);
}

.resend-otp-link {
  display: block;
  text-align: center;
  margin-top: 1rem;
  background: transparent;
  border: none;
  color: var(--brand-600);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.resend-otp-link:hover {
  text-decoration: underline;
}

.resend-otp-link:disabled {
  color: var(--slate-400);
  cursor: not-allowed;
  text-decoration: none;
}

.password-hint {
  font-size: 0.72rem;
  color: var(--slate-400);
  margin-top: -0.5rem;
}

.password-hint.invalid {
  color: var(--rose-600);
}

.password-hint.valid {
  color: #059669;
}

@media (max-width: 480px) {
  .otp-digit {
    width: 2.35rem;
    height: 2.85rem;
    font-size: 1.25rem;
  }

  .otp-input-group {
    gap: 0.35rem;
  }
}

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.form-checkbox {
  width: 1rem;
  height: 1rem;
  color: var(--brand-600);
  border: 1px solid var(--slate-300);
  border-radius: 0.25rem;
}

.checkbox-label {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.submit-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: linear-gradient(to right, var(--brand-600), var(--indigo-600));
  color: white;
  border-radius: 0.75rem;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.submit-btn:hover {
  background: linear-gradient(to right, var(--brand-700), var(--indigo-700));
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

/* บล็อกอย่าง .create-user-section เป็น display:block ธรรมดา (ไม่ใช่ flex) จึงไม่มี gap ให้อัตโนมัติระหว่างแถว .form-grid ที่วางต่อกัน ต้องเติมระยะห่างเอง */
.form-grid + .form-grid {
  margin-top: 1.35rem;
}

.form-grid-wide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.form-col .form-group-grow {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-col .form-group-grow textarea {
  flex: 1;
}

@media (max-width: 640px) {
  .form-grid-wide {
    grid-template-columns: 1fr;
  }
}

.toast {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s;
}

/* ==========================================
   Toast ลอย: แจ้งเตือนทั่วไปทุกหน้า (บันทึกสำเร็จ/ผิดพลาด ฯลฯ) ใช้ร่วมกัน - มีแถบโหลดนับถอยหลังก่อนหายแบบเดียวกับ .form-toast ใน form.css (หน้าลงทะเบียน)
   ========================================== */
.welcome-toast {
  position: fixed;
  top: 5rem;
  left: 50%;
  z-index: 999;
  max-width: 90vw;
  padding: 0.75rem 1.5rem 0.9rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transform: translate(-50%, -0.75rem);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* แถบโหลดวิ่งจากว่างไปจนเต็มความกว้าง พอเต็มพอดีก็ถึงเวลาที่ toast หายไป (ระยะเวลาต้องตรงกับ setTimeout ในฟังก์ชัน showXToast ของแต่ละหน้า) */
.welcome-toast-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background-color: currentColor;
  opacity: 0.45;
  transform-origin: left;
  transform: scaleX(0);
}

.welcome-toast-bar.running {
  transform: scaleX(1);
  transition: transform 3s linear;
}

/* ลิงก์ในเนื้อหาประชาสัมพันธ์ที่แสดงผลจริง (หน้าเว็บสาธารณะ + ตัวอย่างก่อนอนุมัติใน WebManager) ให้เห็นชัดว่ากดได้ */
.news-detail-content a {
  color: var(--brand-600);
  text-decoration: underline;
  font-weight: 600;
  word-break: break-word;
}

.news-detail-content a:hover {
  color: var(--brand-700);
}

/* ==========================================
   Modal: ดูรูปเต็มจอ (เช่น คลิกรูปในตัวอย่างประชาสัมพันธ์) - แสดงรูปเต็ม ไม่ครอบตัด (object-fit: contain) กึ่งกลางจอเสมอ
   ========================================== */
.image-lightbox-modal .modal-backdrop {
  cursor: zoom-out;
}

.image-lightbox-close-btn {
  position: fixed;
  right: 1.25rem;
  top: 1.25rem;
  z-index: 51;
}

.image-lightbox-close-btn button {
  color: white;
  background: rgba(15, 23, 42, 0.5);
  border: none;
  padding: 0.5rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
}

.image-lightbox-close-btn button:hover {
  background: rgba(15, 23, 42, 0.75);
}

/* ป้ายแว่นขยายมุมล่างขวาของรูปประกอบ บอกใบ้ว่ากดดูรูปเต็มได้ (ใช้กับรูปที่แสดงแบบครอบตัด object-cover ซึ่งเผินๆ ดูไม่ออกว่ากดได้) */
.news-detail-zoom-btn {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  color: white;
  background: rgba(15, 23, 42, 0.55);
  border: none;
  padding: 0.45rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
}

.news-detail-zoom-btn:hover {
  background: rgba(15, 23, 42, 0.8);
}

.image-lightbox-img {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  z-index: 51;
}

/* ==========================================
   Modal: Mobile-specific overrides (max-width: 480px)
   ========================================== */
@media (max-width: 480px) {
  .modal-wrapper {
    padding: 0.5rem;
    align-items: center;
  }

  .modal-box {
    border-radius: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-content {
    padding: 1.25rem 1rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-tab {
    font-size: 0.875rem;
  }

  .submit-btn {
    font-size: 0.8rem;
    padding: 0.625rem 0.75rem;
  }
}
