/* ============================================================
   assets/css/ui-kit.css
   ชุดลูกเล่นกลางของเว็บ — โหลดครั้งเดียวใช้ได้ทุกหน้า

   หลักการ:
   - ใช้เฉพาะ transform / opacity ซึ่งการ์ดจอประมวลผลให้ (ลื่น ไม่กินแบต)
   - หลีกเลี่ยง property ที่ทำให้เบราว์เซอร์คำนวณ layout ใหม่ (width/top/left)
   - ปิดอัตโนมัติถ้าผู้ใช้ตั้งค่า "ลดการเคลื่อนไหว" ในเครื่อง
   ============================================================ */

/* ---------- 1. ป็อบอัพทรงสี่เหลี่ยม ---------- */
/* บังคับให้กล่องป็อบอัพทุกตัวในเว็บเป็นทรงสี่เหลี่ยมมุมคมขึ้น */
.order-modal-card,
.aic-modal-box,
.uk-modal-card {
  border-radius: 4px !important;
}

/* --- SweetAlert2 --- */
/* ป็อบอัพส่วนใหญ่ของเว็บ (เข้าสู่ระบบสำเร็จ / บันทึกแล้ว / ยืนยัน ฯลฯ)
   มาจากไลบรารี SweetAlert2 ซึ่งมีมุมมนมาจากตัวมันเอง
   จึงต้อง override ที่นี่ครั้งเดียว ครอบคลุมทั้ง 22 ไฟล์ที่เรียกใช้ */
.swal2-popup {
  border-radius: 4px !important;
}
.swal2-popup .swal2-confirm,
.swal2-popup .swal2-cancel,
.swal2-popup .swal2-deny {
  border-radius: 4px !important;
  font-weight: 700 !important;
  box-shadow: none !important;
}
.swal2-popup .swal2-input,
.swal2-popup .swal2-textarea,
.swal2-popup .swal2-select,
.swal2-popup .swal2-file {
  border-radius: 4px !important;
}
.swal2-container.swal2-backdrop-show,
.swal2-container {
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
/* ไอคอนวงกลมยังคงกลมตามเดิม (ถ้าทำเป็นเหลี่ยมจะดูแปลก) */
.swal2-icon { border-radius: 50% !important; }

.uk-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 20, 45, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.uk-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.uk-modal-card {
  background: #fff;
  border-radius: 4px;
  padding: 26px 24px;
  width: 100%;
  max-width: 400px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 70px rgba(8, 24, 60, .32);
  transform: translateY(14px) scale(.97);
  transition: transform .26s cubic-bezier(.34, 1.4, .64, 1);
}
.uk-modal.show .uk-modal-card {
  transform: translateY(0) scale(1);
}

.uk-modal-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 8px;
}
.uk-modal-text {
  font-size: .93rem;
  color: #475569;
  line-height: 1.7;
  margin: 0 0 20px;
}
.uk-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.uk-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s ease, opacity .12s ease;
}
.uk-btn:active { transform: scale(.96); }
.uk-btn-primary { background: #1877F2; color: #fff; }
.uk-btn-danger  { background: #dc2626; color: #fff; }
.uk-btn-ghost   { background: #eef2f8; color: #0f172a; }
.uk-btn:hover   { opacity: .9; }


/* ---------- 2. Toast แจ้งเตือนมุมจอ ---------- */
.uk-toast-wrap {
  position: fixed;
  z-index: 10000;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.uk-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 220px;
  max-width: 340px;
  padding: 13px 16px;
  border-radius: 4px;
  background: #0f172a;
  color: #fff;
  font-size: .9rem;
  line-height: 1.55;
  box-shadow: 0 12px 34px rgba(8, 24, 60, .3);
  transform: translateY(16px);
  opacity: 0;
  transition: transform .28s cubic-bezier(.34, 1.4, .64, 1), opacity .28s ease;
  pointer-events: auto;
}
.uk-toast.show { transform: translateY(0); opacity: 1; }
.uk-toast.hide { transform: translateY(8px); opacity: 0; }
.uk-toast-ico { flex: none; font-size: 1rem; line-height: 1.5; }
.uk-toast.ok   { background: #14532d; }
.uk-toast.err  { background: #7f1d1d; }
.uk-toast.warn { background: #78350f; }

/* มือถือ: กางเต็มความกว้าง อ่านง่ายกว่า */
@media (max-width: 560px) {
  .uk-toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .uk-toast { max-width: none; width: 100%; }
}


/* ---------- 3. ปุ่มกำลังส่ง (กันกดซ้ำ) ---------- */
.uk-loading {
  position: relative;
  pointer-events: none;
  opacity: .75;
}
.uk-loading > * { visibility: hidden; }
.uk-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ukSpin .6s linear infinite;
  visibility: visible;
}
/* ปุ่มพื้นอ่อน ใช้วงหมุนสีเข้มแทน จะได้มองเห็น */
.uk-loading.uk-on-light::after {
  border-color: rgba(15, 23, 42, .2);
  border-top-color: #0f172a;
}
@keyframes ukSpin { to { transform: rotate(360deg); } }


/* ---------- 4. เนื้อหาค่อยๆ ปรากฏตอนเลื่อนจอ ---------- */
.uk-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease, transform .5s cubic-bezier(.22, 1, .36, 1);
}
.uk-reveal.in {
  opacity: 1;
  transform: none;
}


/* ---------- 5. การ์ดลอยตอนชี้ ---------- */
.uk-lift {
  transition: transform .2s cubic-bezier(.34, 1.3, .64, 1), box-shadow .2s ease;
}
.uk-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(8, 24, 60, .13);
}
.uk-lift:active { transform: translateY(-1px) scale(.995); }


/* ---------- 6. ปุ่มก๊อปปี้ ---------- */
.uk-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid #dbe3f0;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.uk-copy:hover { background: #f4f7fd; border-color: #b9cdf5; }
.uk-copy:active { transform: scale(.95); }
.uk-copy.done { background: #e8f7ee; border-color: #86efac; color: #166534; }


/* ---------- 7. โครงร่างกระพริบระหว่างโหลด ---------- */
.uk-skel {
  background: linear-gradient(90deg, #eef2f8 25%, #f7f9fd 50%, #eef2f8 75%);
  background-size: 200% 100%;
  animation: ukShimmer 1.3s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes ukShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ---------- เคารพการตั้งค่าผู้ใช้ ---------- */
@media (prefers-reduced-motion: reduce) {
  .uk-modal, .uk-modal-card, .uk-toast, .uk-reveal, .uk-lift, .uk-copy, .uk-btn {
    transition: none !important;
    animation: none !important;
  }
  .uk-reveal { opacity: 1 !important; transform: none !important; }
  .uk-skel { animation: none; }
}
