/* ECIP — คอมโพเนนต์ใหม่ + เอฟเฟกต์ทุกหน้า (โหลดต่อจาก styles.css) */

/* ================= Effects: เข้าหน้า · โครงร่างโหลด · toast · ripple ================= */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes arcIn   { from { opacity: 0; transform: scale(.72) rotate(-14deg); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: 200% 0; } }
@keyframes rippleOut { to { transform: translate(-50%, -50%) scale(9); opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px) scale(.96); } }

/* หน้าใหม่จางเข้า + การ์ดไล่ลอยขึ้นทีละใบ */
.view-enter { animation: fadeIn .22s ease both; }
.fx-in { animation: fadeUp .42s cubic-bezier(.2,.7,.3,1) both; animation-delay: var(--d, 0ms); }
.fx-row { animation: fadeIn .34s ease both; animation-delay: var(--d, 0ms); }
.insight { animation: fadeUp .4s cubic-bezier(.2,.7,.3,1) both; animation-delay: var(--d, 0ms); }
.dl-row { animation: slideIn .38s ease both; animation-delay: var(--d, 0ms); }
.donut-svg path { transform-origin: 80px 80px; }

/* การ์ด/ปุ่ม/แถวตาราง ตอบสนองเมื่อชี้และกด */
.card { transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease; }
.view .card:hover { box-shadow: 0 4px 18px rgba(11,11,11,.07); }
.mini-fill, .util-fill { transition: width .8s cubic-bezier(.25,.8,.3,1); }
tbody tr { transition: background .14s ease; }
.btn { position: relative; overflow: hidden; transition: transform .12s ease, box-shadow .15s ease, background .15s ease; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-secondary:hover { background: rgba(11,11,11,.045); border-color: rgba(11,11,11,.2); }
.icon-btn { position: relative; overflow: hidden; transition: background .14s ease, transform .14s ease, color .14s ease; }
.icon-btn:hover { transform: scale(1.14); }
.shell-in .main { animation: fadeIn .35s ease both; }
.shell-in .sidebar { animation: slideIn .35s ease both; }

.ripple {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: currentColor; opacity: .28; pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  animation: rippleOut .6s cubic-bezier(.2,.7,.3,1) forwards;
}

/* โครงร่างระหว่างโหลดข้อมูล (แทนข้อความ "กำลังโหลด…") */
.sk {
  border-radius: 8px; background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
  background-image: linear-gradient(90deg, rgba(11,11,11,.055) 25%, rgba(11,11,11,.11) 37%, rgba(11,11,11,.055) 63%);
}
.sk-card { pointer-events: none; }
.sk-sm { height: 11px; width: 42%; margin-bottom: 10px; }
.sk-lg { height: 26px; width: 66%; margin-bottom: 10px; }
.sk-chart { height: 190px; width: 100%; }
.sk-row { height: 14px; width: 100%; margin-bottom: 9px; }

/* Toast แจ้งผลลัพธ์ (แทน alert ที่ต้องกดปิด) */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--s1);
  border-radius: 10px; padding: 11px 16px; font-size: 13px; max-width: 380px;
  box-shadow: 0 10px 30px rgba(11,11,11,.16);
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.1) both;
}
.toast.out { opacity: 0; transform: translateX(24px); transition: opacity .25s, transform .25s; }
.toast-ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; flex: none; }
.t-ok { border-left-color: var(--good); }
.t-ok .toast-ic { background: var(--good); }
.t-warn { border-left-color: var(--warning); }
.t-warn .toast-ic { background: var(--warning); color: #4a3200; }
.t-err { border-left-color: var(--critical); }
.t-err .toast-ic { background: var(--critical); }
.t-info { border-left-color: var(--s1); }
.t-info .toast-ic { background: var(--s1); }

/* ================= Dashboard: ภาระผูกพัน · ปฏิทินครบกำหนด · สุขภาพข้อมูล · กิจกรรม ================= */
.sect-card { background: linear-gradient(180deg, rgba(42,120,214,.035), transparent 60%); }
.mini-kpis { margin-top: 4px; }
.tile {
  display: block; position: relative; overflow: hidden; text-decoration: none; color: inherit;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tile::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 2px;
  background: linear-gradient(90deg, var(--s1), #7a5cf0);
  transform: scaleX(0); transform-origin: left; transition: transform .35s cubic-bezier(.3,.8,.3,1);
}
.tile:hover { transform: translateY(-3px); border-color: rgba(42,120,214,.4); box-shadow: 0 8px 24px rgba(42,120,214,.14); }
.tile:hover::after { transform: scaleX(1); }
.tile.warn::after { background: linear-gradient(90deg, var(--critical), var(--warning)); }
.tile.warn:hover { border-color: rgba(208,59,59,.4); box-shadow: 0 8px 24px rgba(208,59,59,.14); }
.tile .kpi-value { font-size: 21px; }
.link-more { float: right; font-size: 11.5px; font-weight: 500; color: var(--s1); text-decoration: none; }
.link-more:hover { text-decoration: underline; }
.chip-ok { font-size: 11px; color: var(--good-text); background: rgba(12,163,12,.12); padding: 1px 8px; border-radius: 99px; }

/* ปฏิทินครบกำหนด */
.due-row {
  display: flex; align-items: center; gap: 11px; padding: 9px 6px; border-top: 1px solid var(--grid);
  text-decoration: none; color: inherit; border-radius: 8px;
  animation: fadeUp .4s ease both; animation-delay: var(--d, 0ms);
  transition: background .15s ease, padding-left .15s ease;
}
.due-row:first-of-type { border-top: 0; }
.due-row:hover { background: rgba(42,120,214,.055); padding-left: 12px; }
.due-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; flex: none; }
.k-subscription { background: rgba(42,120,214,.12); }
.k-license { background: rgba(122,92,240,.12); }
.k-contract { background: rgba(235,104,52,.12); }
.due-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.due-name { font-size: 12.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.due-note { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.due-right { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.due-date { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.due-days { font-size: 10.5px; color: var(--muted); }
.due-days.soon { color: #8a5a00; font-weight: 700; }
.due-days.late { color: var(--critical); font-weight: 700; }
.due-amt { width: 78px; flex: none; text-align: right; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.due-amt small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; }

/* ตรวจสุขภาพข้อมูล */
.dq-row {
  display: flex; align-items: flex-start; gap: 11px; padding: 10px 6px; border-top: 1px solid var(--grid);
  text-decoration: none; color: inherit; border-radius: 8px;
  animation: fadeUp .4s ease both; animation-delay: var(--d, 0ms);
  transition: background .15s ease, padding-left .15s ease;
}
.dq-row:first-of-type { border-top: 0; }
.dq-row:hover { background: rgba(11,11,11,.035); padding-left: 12px; }
.dq-ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; flex: none; }
.sev-critical .dq-ic { background: rgba(208,59,59,.14); }
.sev-serious .dq-ic { background: rgba(236,131,90,.16); }
.sev-warning .dq-ic { background: rgba(250,178,25,.16); }
.dq-title { display: block; font-size: 12.6px; font-weight: 600; }
.dq-detail { display: block; font-size: 11.5px; color: var(--ink-2); }
.dq-count {
  flex: none; min-width: 30px; height: 24px; padding: 0 8px; border-radius: 7px;
  display: grid; place-items: center; font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.sev-critical .dq-count { background: rgba(208,59,59,.12); color: var(--critical); }
.sev-serious .dq-count { background: rgba(236,131,90,.16); color: #a2451c; }
.sev-warning .dq-count { background: rgba(250,178,25,.18); color: #8a5a00; }

/* กิจกรรมล่าสุด */
.act-row {
  display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-top: 1px solid var(--grid);
  animation: fadeUp .38s ease both; animation-delay: var(--d, 0ms);
}
.act-row:first-of-type { border-top: 0; }
.act-ic { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.a-create { background: rgba(12,163,12,.13); color: var(--good-text); }
.a-update { background: rgba(42,120,214,.13); color: var(--s1); }
.a-delete { background: rgba(208,59,59,.12); color: var(--critical); }
.a-approve { background: rgba(12,163,12,.16); color: var(--good-text); }
.a-auth { background: rgba(11,11,11,.06); color: var(--ink-2); }
.act-sum { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-meta { display: block; font-size: 11px; color: var(--muted); }
.act-time { flex: none; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ================= หน้าประวัติการใช้งาน (Log) ================= */
.log-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.lf { display: flex; flex-direction: column; gap: 4px; }
.lf > span { font-size: 11px; font-weight: 600; color: var(--ink-2); }
.lf.grow { flex: 1; min-width: 210px; }
.lf.grow .filter { width: 100%; }
input.filter {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; color: var(--ink); font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input.filter:focus, select.filter:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px rgba(42,120,214,.15); }
.lf-actions { display: flex; gap: 6px; }
.lf-actions .btn { padding: 6px 14px; font-size: 12.5px; }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.fchip {
  position: relative; overflow: hidden; cursor: pointer; font-family: inherit;
  border: 1px solid var(--border); background: transparent; border-radius: 99px;
  padding: 4px 12px; font-size: 11.5px; color: var(--ink-2); transition: all .15s ease;
}
.fchip:hover { border-color: rgba(42,120,214,.45); color: var(--s1); }
.fchip.on { background: var(--s1); border-color: var(--s1); color: #fff; }
.fchip b { font-variant-numeric: tabular-nums; }

.log-table td { vertical-align: middle; }
.log-ts { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-user { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.log-user small { display: block; color: var(--muted); font-size: 11px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; flex: none; }
.act-badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
}
.log-row.has-chg { cursor: pointer; }
.log-row.has-chg:hover { background: rgba(42,120,214,.05); }
.log-row.open { background: rgba(42,120,214,.06); }
.chg-toggle { display: inline-block; color: var(--s1); transition: transform .2s ease; }
.log-row.open .chg-toggle { transform: rotate(90deg); }
.chg-count { margin-left: 6px; white-space: nowrap; font-size: 10.5px; color: var(--muted); background: rgba(11,11,11,.05); padding: 1px 7px; border-radius: 99px; }
.chg-detail td { background: rgba(11,11,11,.025); padding: 0; }
.chg-wrap { display: flex; flex-direction: column; gap: 5px; padding: 10px 14px; animation: fadeUp .25s ease both; }
.chg { display: flex; align-items: center; gap: 9px; font-size: 12px; flex-wrap: wrap; }
.chg-label { min-width: 118px; font-weight: 600; color: var(--ink-2); }
.chg-from { background: rgba(208,59,59,.09); color: #8c2c2c; padding: 2px 9px; border-radius: 6px; text-decoration: line-through; }
.chg-arrow { color: var(--muted); }
.chg-to { background: rgba(12,163,12,.11); color: var(--good-text); padding: 2px 9px; border-radius: 6px; font-weight: 600; }

/* ================= แถวที่เพิ่งเพิ่ม (ปักหมุดบนสุดของหน้า 1) ================= */
@keyframes rowNewFlash {
  0%, 45% { background: rgba(42,120,214,.17); }
  100%    { background: rgba(42,120,214,.05); }
}
tbody tr.row-new { animation: rowNewFlash 2.6s ease-out both; }
tbody tr.row-new > td:first-child { box-shadow: inset 3px 0 0 var(--s1); }
tbody tr.row-new:hover { background: rgba(42,120,214,.1); }

/* ================= ต้นทุน NAS & Storage (Settings + ฟอร์มแก้ไข Subscription) ================= */
/* กล่องคำนวณในหน้าต่างแก้ไข Subscription */
.nas-panel {
  border: 1px solid rgba(42,120,214,.28); background: rgba(42,120,214,.04);
  border-radius: 10px; padding: 11px 12px; gap: 8px;
}
.nas-panel > label.ws-check { font-weight: 600; }
.nas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-field input.is-auto { background: rgba(11,11,11,.045); color: var(--ink-2); cursor: not-allowed; }

/* แถวผลลัพธ์การคำนวณ (ใช้ทั้งในฟอร์มและการ์ด Settings) */
.nas-out { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.nas-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 12px; min-width: 0; }
.nas-row > span { color: var(--muted); flex: none; }
.nas-row > b { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nas-row.nas-total { border-top: 1px solid var(--grid); padding-top: 5px; margin-top: 3px; font-size: 12.8px; }
.nas-row.nas-total > b { color: var(--s1); font-weight: 700; }
.nas-sep { border-top: 1px dashed var(--border); margin: 8px 0 6px; }
.nas-note { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
/* บรรทัดแสดงสูตรปันส่วน เช่น 60,000 × (5.00 ÷ 54.7) */
.nas-calc-line {
  font-size: 11.5px; color: var(--s1); font-variant-numeric: tabular-nums;
  text-align: right; padding: 2px 0; letter-spacing: .2px;
}
/* ช่องกรอกพื้นที่ + ตัวเลือกหน่วย GB/TB */
.nas-unit { display: flex; gap: 6px; min-width: 0; }
.nas-unit input { flex: 1; min-width: 0; }
.nas-unit select { flex: none; width: 74px; }

/* ผังการปันส่วนรายแผนก */
.nas-alloc { display: flex; flex-direction: column; gap: 2px; }
.nas-alloc-row {
  display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(90px, 2fr) 92px 66px 104px;
  gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; font-size: 12.2px;
}
.nas-alloc-row:hover { background: rgba(11,11,11,.03); }
.nas-alloc-row.is-rest { color: var(--muted); }
.na-name { display: flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.na-track { height: 12px; background: rgba(11,11,11,.05); border-radius: 4px; overflow: hidden; }
.na-fill { display: block; height: 100%; border-radius: 4px; min-width: 2px; transition: width .8s cubic-bezier(.25,.8,.3,1); }
.na-gb, .na-pct, .na-cost { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.na-pct { color: var(--muted); }
.na-cost { font-weight: 600; }
.nas-warn { font-size: 11.5px; color: #8a5a00; background: rgba(250,178,25,.14); border-radius: 8px; padding: 8px 10px; }

/* การ์ดตั้งค่าต้นทุนในหน้า Settings */
.nas-cfg { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; margin-top: 8px; }
.nas-sum {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: linear-gradient(180deg, rgba(42,120,214,.05), transparent 70%);
  display: flex; flex-direction: column; gap: 3px;
}
.nas-items-head, .nas-item { display: grid; grid-template-columns: 1fr 120px 132px 28px; gap: 6px; align-items: center; }
.nas-items-head { margin: 14px 0 4px; }
.nas-items-head span { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.nas-items-head span.num { text-align: right; }
.nas-item { margin-top: 4px; }
.nas-item input, .nas-item select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 5px 9px; font-size: 12.5px; color: var(--ink); font-family: inherit; min-width: 0;
}
.nas-item input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.nas-item input:focus, .nas-item select:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px rgba(42,120,214,.15); }
.nas-item input:disabled, .nas-item select:disabled { background: rgba(11,11,11,.04); color: var(--ink-2); }

@media (max-width: 1080px) {
  .nas-cfg { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .log-filters { flex-direction: column; align-items: stretch; }
  .lf-actions { justify-content: flex-end; }
  .toasts { left: 14px; right: 14px; align-items: stretch; }
  .toast { max-width: none; }
}

/* เคารพการตั้งค่าของผู้ใช้ที่ปิดภาพเคลื่อนไหวในระบบปฏิบัติการ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
