/* Component dùng chung. Mọi trang import file này. */

/* ---------- Layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--s5);
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s5);
  margin: var(--s4) 0 var(--s7);
  border-radius: var(--r-full);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
}

.topbar__brand {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar__brand span { color: var(--accent); }

.topbar__spacer { flex: 1; }

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row--wrap { flex-wrap: wrap; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-hover); border-color: transparent; }

.btn--danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn--danger:hover { background: var(--danger-soft); border-color: transparent; }

.btn--lg { min-height: 44px; padding: var(--s3) var(--s5); font-size: var(--fs-base); border-radius: var(--r-md); }
.btn--sm { min-height: 40px; padding: var(--s1) var(--s3); font-size: var(--fs-xs); }
.btn--icon { padding: var(--s2); aspect-ratio: 1; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: var(--s2); }
.field__label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-subtle); }
.field__hint { font-size: var(--fs-xs); color: var(--text-faint); }

.input, .textarea, .select {
  width: 100%;
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.select { cursor: pointer; appearance: none; padding-right: var(--s7); }

/* ---------- Switch ---------- */
.switch {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 40px;   /* hit target: track chỉ cao 22px */
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-sm);
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 40px; height: 22px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t-fast);
}
/* Trạng thái đọc từ aria-checked — markup là <button role="switch">, không có <input> */
.switch[aria-checked="true"] .switch__track { background: var(--accent); }
.switch[aria-checked="true"] .switch__track::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; }
.switch:focus-visible .switch__track { box-shadow: var(--ring); }

/* ---------- Card ---------- */
.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  backdrop-filter: blur(var(--blur)) saturate(var(--sat));
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--shadow);
}

.card--pad-sm { padding: var(--s4); }
.card--flat { background: transparent; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 2px var(--s2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge--muted { background: var(--surface-hover); color: var(--text-subtle); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s7) var(--s4);
  text-align: center;
  color: var(--text-subtle);
}
.empty__icon { font-size: 48px; opacity: 0.7; line-height: 1; }
.empty--page { min-height: 52vh; justify-content: center; }
.empty__title { font-weight: 600; color: var(--text); }
.empty__text { font-size: var(--fs-sm); max-width: 46ch; text-wrap: balance; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  bottom: var(--s5);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  z-index: 200;
  pointer-events: none;
  width: min(420px, calc(100vw - var(--s5) * 2));
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  animation: toast-in var(--t-base) ease;
  pointer-events: auto;
}
.toast--error { border-color: var(--danger); color: var(--danger); }
.toast--success { border-color: var(--success); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Modal ---------- */
.modal {
  /* base.css có `*{margin:0}` — giết margin:auto mặc định của dialog khiến nó dính góc */
  margin: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - var(--s5) * 2));
  max-height: calc(100dvh - var(--s6));
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(14, 16, 20, 0.42); backdrop-filter: blur(6px); }
.modal__head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-md); font-weight: 600; flex: 1; }
.modal__body { padding: var(--s5); overflow-y: auto; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
  padding: var(--s4) var(--s5);
  border-top: 1px solid var(--border);
}

/* ---------- Progress ---------- */
.progress {
  height: 4px;
  background: var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--t-base) ease;
}
