/* style เฉพาะของแดชบอร์ดยอดขาย (โหลดหลัง tokens.css และ components.css) */

/* ให้ attribute hidden ชนะ display ของ class เช่น .stack และ .card เสมอ */
[hidden] {
  display: none !important;
}

.app-main {
  padding-top: var(--space-6);
  padding-bottom: var(--space-8);
}

h2 {
  margin: 0;
  font-size: var(--text-xl);
}

/* ----- แถบผู้ใช้ และเข้าสู่ระบบ ----- */
.user-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.user-email {
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.field-error,
.field-hint {
  margin: 0;
}

/* ----- ตัวกรอง ----- */
.filters-bar {
  display: grid;
  gap: var(--space-3);
  align-items: end;
}

@media (min-width: 720px) {
  .filters-bar {
    grid-template-columns: repeat(4, 1fr) auto;
  }
}

.loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  color: var(--color-text-muted);
}

/* ----- KPI ----- */
.kpi-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ตัวเลขยาวขึ้นบรรทัดใหม่ได้บนจอแคบ แทนการดันการ์ดให้กว้างเกินจอ */
.kpi-value {
  overflow-wrap: anywhere;
}

/* ----- กราฟ ----- */
.charts-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 960px) {
  .charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-wide {
    grid-column: 1 / -1;
  }
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
}

.chart-title {
  font-weight: 700;
}

/* Chart.js ใช้ความสูงของกล่องนี้ (maintainAspectRatio: false) */
.chart-box {
  position: relative;
  height: 260px;
}

.chart-summary {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.chart-data summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--color-primary);
  cursor: pointer;
}

.chart-data .table-wrap {
  box-shadow: none;
}

/* ----- ตารางออเดอร์ ----- */
.sort-button {
  min-height: 44px;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
}

/* ส่วน / "" ทำให้ screen reader ไม่อ่านลูกศร (สถานะอ่านจาก aria-sort แทน) */
.sort-button::after {
  content: " ↕" / "";
  color: var(--color-text-muted);
}

th[aria-sort="ascending"] .sort-button::after {
  content: " ↑" / "";
}

th[aria-sort="descending"] .sort-button::after {
  content: " ↓" / "";
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.page-info {
  margin: 0;
  color: var(--color-text-muted);
}
