/* ==========================================================================
   SCIT Personnel System - สไตล์เฉพาะหน้าแดชบอร์ด (dashboard.php)
   ใช้ตัวแปรสีจาก modern.css
   ========================================================================== */

/* ---------- แถบข้อมูล ณ วันที่ + ปุ่มพิมพ์ ---------- */
.ps-dash-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: .95rem;
  color: var(--ps-muted);
}

.ps-dash-caption .far { margin-right: 6px; color: var(--ps-primary); }

/* ---------- แถบแท็บ: แถวเดียว เลื่อนแนวนอน และติดบนเมื่อเลื่อนหน้า ---------- */
.ps-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 18px;
  background: #fff;
  border-bottom: 1px solid var(--ps-border);
  scrollbar-width: thin;
}

.ps-tabs .nav-item { flex: 0 0 auto; }

.ps-tabs .nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: .85rem 1.1rem;
  font-weight: 500;
  white-space: nowrap;
  color: #475569;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  transition: color .2s, border-color .2s, background .2s;
}

.ps-tabs .nav-link .fas { color: #94a3b8; transition: color .2s; }
.ps-tabs .nav-link:hover { color: var(--ps-primary); background: var(--ps-primary-soft); }

.ps-tabs .nav-link.active {
  color: var(--ps-primary);
  font-weight: 600;
  background: transparent;
  border-bottom-color: var(--ps-primary);
}

.ps-tabs .nav-link.active .fas,
.ps-tabs .nav-link:hover .fas { color: var(--ps-primary); }

/* ---------- การ์ดตัวเลขสรุป (แท็บข้อมูลทั่วไป) ---------- */
.kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
  height: calc(100% - 1rem);
  margin-bottom: 1rem;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--ps-border);
  box-shadow: var(--ps-shadow);
  transition: transform .2s, box-shadow .2s;
}

.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--ps-shadow-hover); }

.kpi-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
  border-radius: 14px;
}

.kpi-body { min-width: 0; }
.kpi-label { font-size: .95rem; font-weight: 500; line-height: 1.3; color: var(--ps-muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; color: var(--ps-navy); }
.kpi-unit  { margin-left: 4px; font-size: .9rem; font-weight: 500; color: var(--ps-muted); }

.kpi-blue   .kpi-icon { color: #2563eb; background: #dbeafe; }
.kpi-teal   .kpi-icon { color: #059669; background: #d1fae5; }
.kpi-amber  .kpi-icon { color: #d97706; background: #fef3c7; }
.kpi-violet .kpi-icon { color: #7c3aed; background: #ede9fe; }
.kpi-rose   .kpi-icon { color: #e11d48; background: #ffe4e6; }

/* ---------- กล่องกราฟ / หัวข้อกราฟ ---------- */
#custom-content-below-tabContent .info-box {
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--ps-border);
  box-shadow: var(--ps-shadow);
}

#custom-content-below-tabContent .info-box .info-box-icon { border-radius: 12px; }

.ps-chart    { width: 100%; height: 350px; }
.ps-chart-lg { height: 450px; }

/* หัวข้อของแต่ละกราฟ (รูปแบบเดียวกันทุกแท็บ) */
#custom-content-below-tabContent .tab-pane .row > [class*="col-"] > span:first-child {
  display: block;
  margin-bottom: 10px;
}

#custom-content-below-tabContent .tab-pane .row > [class*="col-"] > span:first-child > b:first-child {
  display: inline-block;
  padding-left: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ps-navy);
  border-left: 4px solid var(--ps-primary);
}

#custom-content-below-tabContent .tab-pane small.text-muted { font-size: .85rem; }

/* ---------- ตารางสรุปข้างกราฟ ---------- */
#custom-content-below-tabContent table.table { border-radius: 12px; overflow: hidden; }
#custom-content-below-tabContent .table td,
#custom-content-below-tabContent .table th { padding: .65rem .85rem; }

.ps-thead,
.ps-thead td,
.ps-thead th {
  font-weight: 600;
  color: var(--ps-navy);
  background-color: #eff6ff !important;
}

/* ตัวเลขที่คลิกดูรายชื่อได้ */
a[data-target="#modal_dt"] {
  display: inline-block;
  min-width: 38px;
  padding: 2px 12px;
  text-align: center;
  font-weight: 600;
  color: var(--ps-primary);
  border-radius: 999px;
  background: var(--ps-primary-soft);
  cursor: pointer;
  transition: background .2s, color .2s;
}

a[data-target="#modal_dt"]:hover {
  color: #fff;
  text-decoration: none;
  background: var(--ps-primary);
}

/* ---------- ตัวกรองหลักสูตรรวมของแท็บ ---------- */
.ps-master {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

.ps-master-label { font-weight: 600; color: var(--ps-navy); }
.ps-master-label .fas { margin-right: 6px; color: var(--ps-primary); }
.ps-master select.form-control { flex: 1 1 220px; max-width: 360px; }

/* ---------- สถานะกำลังโหลด / ไม่มีข้อมูล ---------- */
.ps-loading,
.ps-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 90px;
  color: var(--ps-muted);
}

.ps-empty .far { font-size: 1.4rem; opacity: .6; }

.ps-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #dbeafe;
  border-top-color: var(--ps-primary);
  border-radius: 50%;
  animation: ps-spin .8s linear infinite;
}

@keyframes ps-spin { to { transform: rotate(360deg); } }

/* ---------- modal รายชื่อ ---------- */
#modal_dt .modal-body { max-height: 70vh; overflow-y: auto; }
#modal_dt #TABLE_MODAL a { font-weight: 500; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 767.98px) {
  .ps-tabs .nav-link { padding: .75rem .85rem; }
  .ps-chart { height: 300px; }
  .ps-master select.form-control { max-width: none; }
  .kpi-value { font-size: 1.6rem; }
}

/* ---------- พิมพ์: เฉพาะแท็บที่เปิดอยู่ ---------- */
@media print {
  .main-header, .main-sidebar, .main-footer, .ps-tabs, .ps-dash-caption .btn,
  .ps-master, .preloader, #modal_dt,
  #custom-content-below-tabContent select { display: none !important; }

  .content-wrapper { margin-left: 0 !important; background: #fff !important; }
  .card, .info-box, .kpi-card { box-shadow: none !important; border: 1px solid #ddd !important; }
  .tab-pane { display: none !important; }
  .tab-pane.active { display: block !important; opacity: 1 !important; }
  .info-box, .kpi-card, table { break-inside: avoid; }
}
