/* components.css — bộ class dùng chung theo hợp đồng DOM (MISSION §9).
   Vì sao chỉ dùng var(--token): đổi theme/thương hiệu không phải sửa file này.
   Chữ trên nền đậm dùng --on-brand/--on-warn, lớp phủ dùng --overlay (tokens.css). */

/* ===== Nút ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: 1.5;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--on-brand);
}

.btn-primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand-600);
}

.btn-ghost:hover {
  background: var(--brand-050);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-brand);
}

.btn-danger:hover {
  /* không có token đỏ đậm hơn — tối nhẹ bằng filter thay vì chế hex mới */
  filter: brightness(.9);
}

/* ===== Thẻ ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
}

/* ===== Badge số đỏ (Hộp việc/Kiến thức) ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--sp-1);
  border-radius: 999px;
  background: var(--danger);
  color: var(--on-brand);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
}

/* rỗng = 0 việc chờ → tự ẩn, JS chỉ cần set/xoá textContent */
.badge:empty {
  display: none;
}

/* ===== Empty state có hướng dẫn (§9.5 — không để trang trắng) ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-muted);
}

.empty-icon {
  font-size: 40px;
  line-height: 1;
}

.empty-title {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}

.empty-hint {
  font-size: var(--fs-sm);
  max-width: 360px;
}

/* ===== Toast — góc phải-dưới, trượt vào bằng CSS thuần ===== */
#toast-root {
  position: fixed;
  right: var(--sp-4);
  bottom: var(--sp-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 340px;
}

/* Mobile: sidebar thành thanh dưới cao ~56px — toast phải nằm TRÊN thanh,
   không được che nút điều hướng (§9.1#5 mobile là nơi Sếp dùng nhiều nhất) */
@media (max-width: 767px) {
  #toast-root {
    bottom: calc(56px + var(--sp-4));
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--r);
  box-shadow: var(--shadow-2);
  animation: toast-in .25s ease;
}

.toast-ok {
  border-left-color: var(--ok);
}

.toast-err {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ===== Modal xác nhận (việc không lùi được — §9.5) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: var(--overlay);
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow: auto;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  animation: modal-in .2s ease;
}

/* hàng nút của modal (ui.js tạo) — đẩy về phải theo thói quen đọc */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

@keyframes modal-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ===== Skeleton khi tải (§9.5 — không nhảy layout) =====
   Shimmer bằng nhấp nháy opacity, không gradient (§9.2 cấm gradient). */
.skeleton {
  min-height: 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: .55;
  }
}

/* ===== Banner cảnh báo (mất realtime — dưới topbar) =====
   Chữ black cố định: nền amber sáng ở cả 2 theme, chữ theo theme sẽ
   mất tương phản khi dark. */
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--warn);
  color: var(--on-warn);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-align: center;
}

/* ===== Chấm trạng thái Zalo/SSE ===== */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.warn {
  background: var(--warn);
}

.status-dot.err {
  background: var(--danger);
}

/* ===== Bảng cơ bản (Sản phẩm, Chăm sóc…) ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

/* ===== Form controls ===== */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}

::placeholder {
  color: var(--text-muted);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
}
