/*
 * Design tokens — Cấp nước Thủy An. Nguồn sự thật: DESIGN.md (thư mục gốc).
 * Chỉ khai báo biến; không có selector giao diện. Trang mới dùng var(--ta-*),
 * không viết mã màu/khoảng cách rời rạc.
 */
:root {
  color-scheme: light;

  /* Kiểu chữ */
  /* "Inter" chỉ là tập chữ số (unicode-range) nạp ở app.html: chữ số đều cho tiền/chỉ số;
     mọi chữ cái rơi về Be Vietnam Pro. */
  --ta-font: "Inter", "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ta-text-xs: 12px;
  --ta-text-sm: 13px;
  --ta-text-md: 14px;   /* chữ thân mặc định */
  --ta-text-lg: 16px;
  --ta-text-xl: 20px;   /* tiêu đề trang */
  --ta-text-2xl: 24px;  /* số KPI */
  --ta-text-num: 32px;  /* số đo HMI, chỉ số đồng hồ */
  --ta-leading-tight: 1.25;
  --ta-leading: 1.5;
  --ta-weight-regular: 400;
  --ta-weight-medium: 500;
  --ta-weight-strong: 600;

  /* Khoảng cách — lưới 4px */
  --ta-space-1: 4px;
  --ta-space-2: 8px;
  --ta-space-3: 12px;
  --ta-space-4: 16px;
  --ta-space-5: 20px;
  --ta-space-6: 24px;
  --ta-space-8: 32px;
  --ta-space-10: 40px;
  --ta-gutter: 24px;

  /* Kích thước điều khiển */
  --ta-control-sm: 28px;
  --ta-control-md: 32px;
  --ta-control-lg: 40px;
  --ta-touch: 44px;     /* vùng chạm tối thiểu trên điện thoại */
  --ta-row-compact: 36px;
  --ta-row: 44px;

  /* Bo góc — theo thứ bậc, không một số cho mọi thứ */
  --ta-radius-sm: 4px;  /* nút, ô nhập, nhãn trạng thái */
  --ta-radius-md: 6px;  /* khối nội dung, bảng */
  --ta-radius-lg: 8px;  /* hộp thoại, ngăn kéo, menu nổi */

  /* Màu nền tảng: "nước sâu" cho khung, xanh nước cho thao tác */
  --ta-deep-900: #0b3446;
  --ta-deep-800: #12465c;
  --ta-deep-700: #1b5a73;
  --ta-deep-line: #2a5568;
  --ta-deep-text: #c5d7df;
  --ta-deep-muted: #8eaab7;
  --ta-deep-focus: #8fd3e3;

  --ta-canvas: #f2f5f7;
  --ta-surface: #ffffff;
  --ta-surface-sunken: #f7f9fa;
  --ta-surface-hover: #eef3f6;
  --ta-surface-selected: #e7f0f8;

  --ta-border: #d8e0e6;
  --ta-border-strong: #b5c2cc;
  --ta-border-input: #8696a3;

  --ta-text: #13212b;
  --ta-text-secondary: #4a5c69;
  --ta-text-tertiary: #5d6d79;
  --ta-text-disabled: #9aa7b1;
  --ta-text-on-accent: #ffffff;

  --ta-accent: #1565a8;
  --ta-accent-hover: #0f548e;
  --ta-accent-active: #0b4475;
  --ta-accent-subtle: #e7f0f8;
  --ta-accent-border: #b9d3ea;
  --ta-focus: #1565a8;

  /* Trạng thái nghiệp vụ: luôn đi kèm chữ/biểu tượng, không dùng màu đơn độc */
  --ta-success: #18794e;
  --ta-success-bg: #e8f5ee;
  --ta-success-border: #a9d8bf;
  --ta-warning: #9a5200;
  --ta-warning-mark: #d97706;
  --ta-warning-bg: #fff4e0;
  --ta-warning-border: #f2cb8a;
  --ta-danger: #b42318;
  --ta-danger-mark: #d92d20;
  --ta-text-on-danger: #ffffff;  /* chữ trên nút đỏ đặc: 4,83:1 (thường), 6,57:1 (rê chuột) */
  --ta-danger-bg: #fdecea;
  --ta-danger-border: #f3b4ae;
  --ta-neutral: #4a5c69;
  --ta-neutral-bg: #eef2f5;
  --ta-neutral-border: #cfd8df;

  /* HMI (Giám sát trạm): bình thường = xám, chỉ bất thường mới có màu */
  --ta-hmi-value: #13212b;
  --ta-hmi-stale: #63737f;
  --ta-hmi-stale-bg: repeating-linear-gradient(135deg, #eef2f5 0 6px, #f7f9fa 6px 12px);
  --ta-hmi-offline: #4a5c69;
  --ta-hmi-alarm: #d92d20;
  --ta-hmi-warn: #d97706;

  /* Biểu đồ */
  --ta-chart-1: #1565a8;  /* nước sạch, mực nước */
  --ta-chart-2: #6c7f3a;  /* nước thô */
  --ta-chart-3: #2b8a8a;
  --ta-chart-4: #6e5ba8;
  --ta-chart-grid: #e3e9ed;
  --ta-chart-axis: #63737f;

  /* Độ nổi: khối nằm phẳng có viền; chỉ lớp nổi mới có bóng */
  --ta-shadow-overlay: 0 6px 20px rgb(11 52 70 / 14%);
  --ta-shadow-dialog: 0 16px 48px rgb(11 52 70 / 22%);
  --ta-scrim: rgb(8 25 35 / 48%);

  /* Chuyển động */
  --ta-dur-fast: 120ms;
  --ta-dur: 180ms;
  --ta-ease: cubic-bezier(.2, 0, 0, 1);

  /* Lớp chồng */
  --ta-z-sticky: 10;
  --ta-z-dropdown: 30;
  --ta-z-drawer: 40;
  --ta-z-dialog: 50;
  --ta-z-toast: 60;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ta-deep-900: #0a2532;
  --ta-deep-800: #10384a;
  --ta-deep-700: #174a60;
  --ta-deep-line: #24485a;

  --ta-canvas: #0f1b23;
  --ta-surface: #16252f;
  --ta-surface-sunken: #132029;
  --ta-surface-hover: #1c2f3b;
  --ta-surface-selected: #183a55;

  --ta-border: #2b3f4c;
  --ta-border-strong: #3d5463;
  --ta-border-input: #6b8191;

  --ta-text: #e4ecf1;
  --ta-text-secondary: #a9bac5;
  --ta-text-tertiary: #8a9eab;
  --ta-text-disabled: #5d7280;
  --ta-text-on-accent: #06243a;

  --ta-accent: #6cb4ec;
  --ta-accent-hover: #8ec6f1;
  --ta-accent-active: #b0d7f5;
  --ta-accent-subtle: #163650;
  --ta-accent-border: #275d86;
  --ta-focus: #8ec6f1;

  --ta-success: #6fd3a0;
  --ta-success-bg: #12322a;
  --ta-success-border: #24583f;
  --ta-warning: #f5bc6a;
  --ta-warning-mark: #f59e0b;
  --ta-warning-bg: #3a2a10;
  --ta-warning-border: #6b4c18;
  --ta-danger: #ff9a8f;
  --ta-danger-mark: #f0645a;
  --ta-text-on-danger: #2a0805;  /* nền đỏ sáng ở chế độ tối: chữ trắng chỉ 3,15:1 → chữ tối 5,88:1 / 9,05:1 */
  --ta-danger-bg: #3d1b1a;
  --ta-danger-border: #6e2f2b;
  --ta-neutral: #a9bac5;
  --ta-neutral-bg: #1d2c36;
  --ta-neutral-border: #34495a;

  --ta-hmi-value: #e4ecf1;
  --ta-hmi-stale: #8a9eab;
  --ta-hmi-stale-bg: repeating-linear-gradient(135deg, #1a2a34 0 6px, #16252f 6px 12px);
  --ta-hmi-offline: #a9bac5;
  --ta-hmi-alarm: #f0645a;
  --ta-hmi-warn: #f59e0b;

  --ta-chart-1: #6cb4ec;
  --ta-chart-2: #b3c27c;
  --ta-chart-3: #5cc4c4;
  --ta-chart-4: #a898e0;
  --ta-chart-grid: #24363f;
  --ta-chart-axis: #8a9eab;

  --ta-shadow-overlay: 0 6px 20px rgb(0 0 0 / 40%);
  --ta-shadow-dialog: 0 16px 48px rgb(0 0 0 / 55%);
}

@media (width < 900px) {
  :root { --ta-gutter: 16px; }
}
