/* ═══════════════════════════════════════════════════════
   Nebrix — UX ส่วนกลาง 0.29.0 (Admin Portal + Hub)
   แถบความคืบหน้าบนสุด · ปุ่มกำลังทำงาน · ข้อความแจ้งผล (toast) · skeleton
   ใช้ตัวแปรธีมเดิมของ nebrix-admin.css (--accent --surface --tx --b2 --s2 --s3 --green --red --amber --muted) · html.light = สว่าง
═══════════════════════════════════════════════════════ */
.nx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── แถบความคืบหน้าบนสุด ───────────────────────────── */
.nx-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
.nx-progress.on { opacity: 1; }
.nx-progress-bar { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: var(--accent, #6366f1);
    box-shadow: 0 0 8px var(--accent, #6366f1); border-radius: 0 2px 2px 0; }
.nx-progress.on .nx-progress-bar { animation: nx-progress 1.1s ease-in-out infinite; }
@keyframes nx-progress { 0% { left: -40%; width: 40%; } 60% { width: 55%; } 100% { left: 100%; width: 30%; } }

/* ── ปุ่มที่กำลังทำงาน (AsyncButton) ──────────────────── */
.nx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.nx-btn.nx-busy, .nx-btn[aria-busy="true"] { cursor: progress; opacity: .85; }
.nx-btn:disabled:not(.nx-busy) { cursor: not-allowed; opacity: .55; }
.nx-spin { width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
    animation: nx-spin .7s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes nx-spin { to { transform: rotate(360deg); } }

/* ฟอร์ม POST แบบ static SSR (สคริปต์ใน App.razor) */
form[data-nx-busy] button[type="submit"], form[data-nx-busy] input[type="submit"] { cursor: progress; }

/* ── ข้อความแจ้งผล (toast) ───────────────────────────── */
.nx-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 8px;
    width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.nx-toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 10px;
    background: var(--surface, #16181f); color: var(--tx, #e8e9ef); border: 1px solid var(--b2, rgba(255,255,255,.12));
    border-left: 4px solid var(--accent, #6366f1); box-shadow: 0 10px 30px rgba(0,0,0,.28); font-family: var(--font); font-size: 14px; line-height: 1.5;
    animation: nx-toast-in .18s ease-out; }
html.light .nx-toast { box-shadow: 0 12px 32px rgba(17,24,39,.16); }
.nx-toast.ok   { border-left-color: var(--green, #10b981); }
.nx-toast.err  { border-left-color: var(--red, #ef4444); }
.nx-toast.warn { border-left-color: var(--amber, #f59e0b); }
.nx-toast-ic { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff; background: var(--accent, #6366f1); margin-top: 1px; }
.nx-toast.ok .nx-toast-ic   { background: var(--green, #10b981); }
.nx-toast.err .nx-toast-ic  { background: var(--red, #ef4444); }
.nx-toast.warn .nx-toast-ic { background: var(--amber, #f59e0b); }
.nx-toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.nx-toast-x { background: none; border: 0; color: var(--muted, #6b7280); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px; }
.nx-toast-x:hover { color: var(--tx); background: var(--s2); }
.nx-toast-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@keyframes nx-toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) { .nx-toasts { right: 16px; left: 16px; bottom: 16px; width: auto; } }

/* ── skeleton ───────────────────────────────────────── */
.nx-skel { display: block; height: 12px; border-radius: 6px; background: var(--s3, rgba(255,255,255,.08)); position: relative; overflow: hidden; }
.nx-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); animation: nx-shimmer 1.3s infinite; }
html.light .nx-skel::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); }
@keyframes nx-shimmer { to { transform: translateX(100%); } }
.nx-skel.h14 { height: 14px; } .nx-skel.h24 { height: 24px; }
.nx-skel.w15 { width: 15%; } .nx-skel.w20 { width: 20%; } .nx-skel.w25 { width: 25%; } .nx-skel.w30 { width: 30%; } .nx-skel.w40 { width: 40%; }
.nx-skel.w60 { width: 60%; } .nx-skel.w80 { width: 80%; } .nx-skel.w100 { width: 100%; }
.nx-skel-wrap { padding: 4px 0; }
.nx-skel-lines { display: flex; flex-direction: column; gap: 10px; }
.nx-skel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.nx-skel-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 12px; border: 1px solid var(--b1, rgba(255,255,255,.06)); background: var(--surface); }
.nx-skel-table { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; }
.nx-skel-row { display: flex; gap: 16px; }
.nx-skel-row .nx-skel { flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
    .nx-progress.on .nx-progress-bar { animation: none; left: 0; width: 100%; opacity: .6; }
    .nx-spin { animation-duration: 2s; }
    .nx-skel::after, .nx-toast { animation: none; }
}
