/*
  COMPONENTS — các khối UI dùng lại ở từ 2 module trở lên (card, badge, button, form, row...).
  Đây là "thư viện component" nhắc tới ở CLAUDE.md mục 2 (/shared-ui).
  QUY TẮC: một class ở đây phải được ít nhất 2 module dùng. Nếu chỉ 1 module dùng, chuyển
  xuống css/modules/<module>.css — xem .claude/skills/design-system/SKILL.md mục 4.
*/

/* --- Card & bố cục lưới --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 15px 17px; box-shadow: var(--shadow-card); }

.card-title {
  font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
  margin: 0 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

.grid { display: grid; gap: 13px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* --- Metric Summary Card (spec mục 4.1) --- */
.stat-label { font-size: 12px; color: var(--ink-muted); margin: 0 0 5px; }
.stat-value { font-size: 25px; font-weight: 700; margin: 0; line-height: 1.15; }
.stat-value.sm { font-size: 15px; font-weight: 600; padding-top: 6px; }
.stat-value.is-red { color: var(--red); }
.stat-value.is-sage { color: var(--sage); }
.stat-value.is-accent { color: var(--accent); }
.stat-value.is-amber { color: var(--amber); }
.stat-sub { font-size: 12px; color: var(--ink-muted); margin: 4px 0 0; }

/* Active (gradient fill + chữ trắng) vs Inactive (card trắng, chữ tối) */
.stat-card.is-primary {
  background: linear-gradient(155deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 12px 26px -12px var(--accent-shadow);
}
.stat-card.is-primary .stat-label { color: rgba(255, 255, 255, .78); }
.stat-card.is-primary .stat-value { color: #fff; }

/* --- Row (dòng item trong danh sách) --- */
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0 9px 10px; border-bottom: 1px solid var(--line); position: relative; }
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { margin: 0; font-size: 13.5px; font-weight: 600; }
.row-sub { margin: 1px 0 0; font-size: 12px; color: var(--ink-muted); }

.row-accent::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 100px; background: var(--ink-muted);
}
.row-accent-blue::before { background: var(--accent); }
.row-accent-amber::before { background: var(--amber); }
.row-accent-sage::before { background: var(--sage); }
.row-accent-red::before { background: var(--red); }
.row-accent-violet::before { background: var(--violet); }

/* --- Badge / pill trạng thái --- */
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 100px; white-space: nowrap; display: inline-block; }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-sage { background: var(--sage-soft); color: var(--sage); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-plain { background: var(--surface-muted); color: var(--ink-muted); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; color: var(--accent);
}

/* --- Form: input/select/textarea/label --- */
input[type="text"], input[type="date"], input[type="number"], input[type="password"], select, textarea,
.select-trigger {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
label { font-size: 12px; color: var(--ink-muted); display: block; margin: 0 0 4px; }
.field { margin-bottom: 11px; }

/*
  --- Dropdown tùy biến thay cho popup gốc của <select> ---
  Dựng tự động bởi js/ui.js (DU.ui.enhanceAll) cho MỌI <select> trong app — không cần module
  nào tự viết CSS này. Cùng ngôn ngữ hình ảnh với .lang-menu ở css/layout.css.
*/
/* Không ép width cố định — để shell tự co giãn theo đúng độ rộng của trigger bên trong (trigger
   kế thừa class của select gốc, nên select nào width:auto như .ag-filter thì shell cũng hẹp
   theo, còn select thường width:100% thì shell cũng lấp đầy field — khớp layout gốc trước khi
   có dropdown tùy biến). */
.select-shell { position: relative; display: inline-block; max-width: 100%; }
.select-native.select-native { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

.select-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; text-align: left; appearance: none;
  font: inherit; font-weight: inherit;
}
.select-trigger:disabled { opacity: .55; cursor: default; }
.select-trigger::after {
  content: ""; flex-shrink: 0; margin-top: -3px;
  width: 7px; height: 7px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  opacity: .55; transform: rotate(45deg); transition: transform .15s ease;
}
.select-shell.is-open .select-trigger::after { transform: rotate(-135deg); margin-top: 3px; }

.select-menu[hidden] { display: none; }
.select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  padding: 5px;
  max-height: 260px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.select-option {
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13.5px; color: var(--ink);
  cursor: pointer;
  transition: background .1s ease, color .1s ease;
}
.select-option.is-active { background: var(--surface-muted); color: var(--ink); }
.select-option.is-selected { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* --- Button --- */
.btn {
  padding: 8px 15px; border-radius: 100px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; font-weight: 600;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 8px 18px -10px var(--accent-shadow); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { border-radius: 100px; border-color: transparent; background: transparent; color: var(--ink-muted); padding: 4px 8px; }
.btn-icon:hover { background: var(--red-soft); color: var(--red); }

/* --- Progress bar --- */
.progress-track { height: 8px; border-radius: 100px; background: var(--surface-muted); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--sage-2)); border-radius: 100px; transition: width .25s ease; }

/* --- Trạng thái task inline (dropdown màu) --- */
.status-select { width: auto; padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: 100px; }
.status-select.st-todo { background: var(--surface-muted); color: var(--ink-muted); }
.status-select.st-doing { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.status-select.st-late { background: var(--red-soft); color: var(--red); border-color: transparent; }
.status-select.st-done { background: var(--sage-soft); color: var(--sage); border-color: transparent; }

/* --- Notice / thông báo inline trong nội dung --- */
.notice { font-size: 12.5px; padding: 10px 13px; border-radius: var(--radius); margin-bottom: 13px; line-height: 1.6; }
.notice-amber { background: var(--amber-soft); color: var(--amber); }
.notice-red { background: var(--red-soft); color: var(--red); }
.notice-accent { background: var(--accent-soft); color: var(--accent); }

.settings-block { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); }
.settings-block summary { cursor: pointer; font-size: 12.5px; color: var(--ink-muted); font-weight: 600; }

.empty-hint { font-size: 12.5px; color: var(--ink-muted); padding: 8px 0; margin: 0; line-height: 1.6; }

.module-intro { margin-bottom: 16px; }
.module-intro p { margin: 0; font-size: 12.5px; color: var(--ink-muted); line-height: 1.6; }

.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
