/* ============================================================
   Psych Dashboard — Styles
   ============================================================ */

* { font-family: 'Sarabun', sans-serif; box-sizing: border-box; }
body { background: #f0f2f7; padding: 0 !important; }
.wr-main-content { padding-left: 0; padding-right: 0; padding-bottom: 0; }
.dash-main { padding: 1.25rem 1.5rem; max-width: 1600px; }

/* ── Page Header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.page-header h1 {
  font-size: 1.25rem; font-weight: 800; color: #0d1b4b; margin: 0;
  display: flex; align-items: center; gap: 0.5rem;
}
.page-header h1 .icon-box {
  width: 34px; height: 34px; border-radius: 0.6rem;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
}
.page-header .subtitle {
  font-size: 0.75rem; color: #64748b; margin-top: 0.15rem;
}

/* ── Filter Toggle & Refresh ── */
.filter-toggle-btn {
  background: linear-gradient(135deg, #0d1b4b, #1a2f6b);
  color: #fff; border: none; border-radius: 0.6rem;
  padding: 0.4rem 1rem; font-weight: 700; font-size: 0.8rem;
  cursor: pointer; transition: all 0.25s; box-shadow: 0 2px 8px rgba(13,27,75,.25);
  display: flex; align-items: center; gap: 0.35rem;
}
.filter-toggle-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(13,27,75,.35); }

.btn-refresh {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff; border: none; border-radius: 0.6rem;
  padding: 0.4rem 1rem; font-weight: 700; font-size: 0.8rem;
  cursor: pointer; transition: all 0.25s; box-shadow: 0 2px 8px rgba(5,150,105,.25);
  display: flex; align-items: center; gap: 0.35rem;
}
.btn-refresh:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(5,150,105,.35); }

/* ── Filter Panel ── */
.filter-panel {
  background: #fff; border-radius: 0.85rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
  margin-bottom: 1rem; overflow: hidden;
  border: 1px solid #e2e8f0;
  animation: slideDown 0.25s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.filter-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1.25rem; border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}
.filter-panel-header h2 {
  font-size: 0.9rem; font-weight: 700; color: #334155;
  display: flex; align-items: center; gap: 0.4rem; margin: 0;
}
.filter-panel-header h2 i { color: #3b82f6; }
.filter-close-btn {
  background: #f1f5f9; border: none; border-radius: 0.5rem;
  padding: 0.3rem 0.85rem; font-size: 0.8rem; font-weight: 600;
  color: #64748b; cursor: pointer; transition: all 0.15s;
}
.filter-close-btn:hover { background: #e2e8f0; color: #334155; }

.filter-body { padding: 0.75rem 1.25rem 1rem; }

/* ── Summary Cards ── */
.summary-cards {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem; margin-bottom: 1rem;
}
.summary-card {
  border-radius: 0.75rem; padding: 0.65rem 0.9rem;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 0.65rem;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.summary-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }
.summary-card .sc-icon {
  width: 42px; height: 42px; border-radius: 0.6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.summary-card .sc-text .card-label {
  font-size: 0.7rem; font-weight: 600; margin-bottom: 0; opacity: 0.85;
}
.summary-card .sc-text .card-value {
  font-size: 1.5rem; font-weight: 800; line-height: 1.1;
}
.summary-card--total {
  background: linear-gradient(135deg, #0d1b4b 0%, #1a3a7a 100%); color: #fff;
}
.summary-card--total .sc-icon { background: rgba(255,255,255,.15); color: #93c5fd; }

.summary-card--drug {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); color: #fff;
}
.summary-card--drug .sc-icon { background: rgba(255,255,255,.15); color: #fca5a5; }

.summary-card--blue {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); color: #fff;
}
.summary-card--blue .sc-icon { background: rgba(255,255,255,.15); color: #93c5fd; }

.summary-card--green {
  background: linear-gradient(135deg, #059669 0%, #047857 100%); color: #fff;
}
.summary-card--green .sc-icon { background: rgba(255,255,255,.15); color: #6ee7b7; }

.summary-card--warning {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%); color: #fff;
}
.summary-card--warning .sc-icon { background: rgba(255,255,255,.15); color: #fde68a; }

/* ── Chart Cards ── */
.chart-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.04);
  margin-bottom: 0;
  height: 100%;
}
.chart-title {
  font-weight: 800; font-size: 1rem; color: #1e293b;
  margin-bottom: 0.75rem; display: flex; align-items: center;
}
.chart-subtitle {
  font-size: 0.78rem; color: #64748b; text-align: center;
  margin-bottom: 0.5rem;
}
.chart-wrapper { position: relative; }
.chart-note {
  text-align: center; font-size: 0.78rem; color: #dc2626;
  font-weight: 600; margin-top: 0.5rem;
  padding: 0.35rem 0.75rem; background: #fef2f2;
  border-radius: 0.4rem; display: inline-block;
  width: 100%;
}

/* ── Monitoring Table ── */
.monitor-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem; margin-top: 1rem;
}
.monitor-table th {
  background: #0d1b4b; color: #fff;
  padding: 0.55rem 0.75rem; font-weight: 700;
  font-size: 0.78rem; text-align: center;
  border: 1px solid rgba(255,255,255,.12);
}
.monitor-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  text-align: center;
}
.monitor-table tbody tr:hover { background: #f8fafc; }
.monitor-table tfoot td {
  background: #0a1435; color: #fff;
  font-weight: 700; border: 1px solid rgba(255,255,255,.1);
}

.color-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font-size: 0.7rem; margin-right: 0.35rem;
  vertical-align: middle;
}
.color-badge--red { background: #dc2626; }
.color-badge--orange { background: #f97316; }
.color-badge--blue { background: #3b82f6; }

/* ── Province Detail Table ── */
.province-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 0.78rem; margin-bottom: 0;
}
.province-table th,
.province-table td {
  padding: 0.45rem 0.4rem; text-align: center;
  border: 1px solid #e2e8f0; vertical-align: middle;
}

/* Header styles */
.province-table .th-index,
.province-table .th-province {
  background: #0d1b4b; color: #fff; font-weight: 700;
  font-size: 0.82rem; border-color: rgba(255,255,255,.12);
}
.province-table .th-group-drug {
  background: #1a3355; color: #fff; font-weight: 700;
  font-size: 0.8rem; border-color: rgba(255,255,255,.12);
}
.province-table .th-group-psych {
  background: #22306a; color: #fff; font-weight: 700;
  font-size: 0.8rem; border-color: rgba(255,255,255,.12);
}
.province-table .th-group-blue {
  background: #0e3460; color: #fff; font-weight: 700;
  font-size: 0.75rem; border-color: rgba(255,255,255,.12);
}
.province-table .th-group-law {
  background: #1b2a4a; color: #fff; font-weight: 700;
  font-size: 0.75rem; border-color: rgba(255,255,255,.12);
}

.province-table .th-sub {
  font-size: 0.72rem; font-weight: 600;
  color: rgba(255,255,255,.85);
  border-color: rgba(255,255,255,.08);
}
.province-table .th-sub-drug { background: #234575; }
.province-table .th-sub-psych { background: #2c4082; }
.province-table .th-sub-blue { background: #174880; }
.province-table .th-sub-law { background: #253a60; }

/* Body */
.province-table tbody td {
  background: #fff; font-weight: 500;
  transition: background 0.15s;
}
.province-table tbody tr:nth-child(even) td { background: #f9fafb; }
.province-table tbody tr:hover td { background: #f0f9ff; }

/* Colored cells */
.cell-red { background: #fef2f2 !important; color: #dc2626; font-weight: 700 !important; }
.cell-orange { background: #fff7ed !important; color: #ea580c; font-weight: 700 !important; }
.cell-yellow { background: #fefce8 !important; color: #ca8a04; font-weight: 700 !important; }
.cell-green { background: #f0fdf4 !important; color: #16a34a; font-weight: 700 !important; }
.cell-blue { background: #eff6ff !important; color: #2563eb; font-weight: 700 !important; }
.cell-total { font-weight: 800 !important; color: #0d1b4b; }

/* Footer total */
.province-table tfoot td {
  background: #0a1435; color: #fff;
  font-weight: 700; font-size: 0.85rem;
  padding: 0.65rem 0.5rem;
  border: 1px solid rgba(255,255,255,.1);
}

/* Expandable table */
#provinceDetailTable { max-height: 500px; overflow-y: auto; }
#provinceDetailTable.expanded { max-height: none; }

/* Sticky header */
.province-table thead th { position: sticky; top: 0; z-index: 10; }

/* ── Full Page Loader ── */
.full-page-loader {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, rgba(13,27,75,0.95) 0%, rgba(10,20,53,0.98) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 2rem; transition: opacity 0.4s;
}
.loader-badge { width: 80px; height: 80px; animation: loaderPulse 2s ease-in-out infinite; filter: drop-shadow(0 0 20px rgba(200,170,80,0.4)); }
@keyframes loaderPulse { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.08); opacity: 1; } }
.loader-bar-track { width: 220px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.loader-bar-fill { width: 40%; height: 100%; background: linear-gradient(90deg, #c8aa50, #f0d060, #c8aa50); border-radius: 2px; animation: loaderBarSlide 1.5s ease-in-out infinite; }
@keyframes loaderBarSlide { 0% { width: 10%; margin-left: 0; } 50% { width: 50%; margin-left: 25%; } 100% { width: 10%; margin-left: 90%; } }
.loader-text { color: rgba(255,255,255,0.85); font-size: 0.95rem; font-weight: 500; margin: 0; }
.loader-subtext { color: rgba(255,255,255,0.45); font-size: 0.78rem; margin: 0; }

/* ── Timestamp ── */
.timestamp { text-align: right; font-size: 0.78rem; color: #64748b; margin-top: 0.75rem; }

/* ── Responsive ── */
@media (max-width: 991px) {
  .dash-main { padding: 1rem; }
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .summary-card .sc-text .card-value { font-size: 1.2rem; }
}
@media (max-width: 576px) {
  .summary-cards { grid-template-columns: 1fr; }
}
