/* ---------- Icon ---------- */
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn-soft { background: var(--tint); color: var(--primary-strong); }
.btn-soft:hover { background: var(--bg-soft); color: var(--primary-strong); border-color: var(--border); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-strong); }
.btn-text { background: none; color: var(--primary-strong); padding-inline: 10px; }
.btn-text:hover { background: var(--bg-soft); }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.875rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled],
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.7; }

/* ---------- Thẻ ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card-soft { background: var(--bg-soft); box-shadow: none; }
.card h3 { margin-bottom: 6px; }
.card p:last-child { margin-bottom: 0; }

.icon-box {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--tint);
  color: var(--primary-strong);
  margin-bottom: 12px;
}

/* ---------- Nhãn ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--tint);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
}
.badge-soon {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

/* ---------- Ô nhập ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label,
.field > .label { font-weight: 500; font-size: 0.9rem; }
.field .hint { font-size: 0.8rem; color: var(--text-muted); }

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--text);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder,
.textarea::placeholder { color: var(--text-muted); }
.input:focus,
.select:focus,
.textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--tint); }

.field-row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
}
.segmented input:checked + label { background: var(--tint); border-color: var(--primary); color: var(--primary-strong); font-weight: 600; }
.segmented input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- Chip lọc ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary-strong); }
.chip.is-active { background: var(--tint); border-color: var(--primary); color: var(--primary-strong); font-weight: 600; }

/* ---------- Đầu trang ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}
.brand {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}
.brand:hover { color: var(--text); }
.brand span { color: var(--primary); }

.nav-toggle { display: inline-flex; }
.site-nav {
  position: fixed;
  inset: 64px 0 auto 0;
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
.site-nav.is-open { display: flex; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg-soft); color: var(--primary-strong); }
.nav-link.is-active { background: var(--tint); color: var(--primary-strong); }
.nav-sep { height: 1px; background: var(--border); margin: 6px 0; }
.nav-actions { display: flex; flex-direction: column; gap: 8px; }

@media (min-width: 1080px) {
  .site-header .nav-toggle { display: none; }
  .site-nav {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 0;
    border: 0;
    box-shadow: none;
    max-height: none;
    overflow: visible;
    background: none;
  }
  .nav-sep { width: 1px; height: 24px; margin: 0 6px; }
  .nav-actions { flex-direction: row; align-items: center; }
  .nav-link { padding: 8px 12px; }
}

/* ---------- Bảng Giao diện ---------- */
.theme-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.theme-dialog::backdrop { background: rgba(30, 42, 68, 0.35); }
.theme-dialog form { padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; font-size: 1.35rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid transparent;
  border-radius: var(--radius-btn);
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--primary-strong); }
.theme-group { border: 0; padding: 0; margin: 18px 0 0; }
.theme-group legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.theme-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-option { position: relative; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option label {
  display: grid;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: var(--surface);
}
.theme-option label:hover { border-color: var(--primary); }
.theme-option input:checked + label { border-color: var(--primary); background: var(--bg-soft); box-shadow: 0 0 0 2px var(--tint); }
.theme-option input:focus-visible + label { outline: 3px solid var(--primary); outline-offset: 2px; }
.theme-name { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 0.95rem; }
.theme-name .icon { color: var(--primary); visibility: hidden; }
.theme-option input:checked + label .theme-name .icon { visibility: visible; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(30, 42, 68, 0.12); }
.font-sample { font-size: 1.05rem; line-height: 1.3; color: var(--text-2); }
.font-sample b { display: block; font-size: 1.2rem; color: var(--text); }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; margin-top: 20px; }

/* ---------- Thông báo nhỏ ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-btn);
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 0.9rem;
}
.toast[hidden] { display: none; }

/* ---------- Chân trang ---------- */
.site-footer {
  margin-top: 40px;
  padding: 32px 0 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.9rem;
}
.footer-grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.footer-grid h3 { font-size: 1rem; margin-bottom: 8px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.footer-grid a { color: var(--text-2); text-decoration: none; display: inline-block; padding: 4px 0; }
.footer-grid a:hover { color: var(--primary-strong); text-decoration: underline; }
.footer-bottom { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Trang hai cột ---------- */
.page-head { padding: 32px 0 8px; }
.page-head p { color: var(--text-2); max-width: 680px; }
.two-col { display: grid; gap: 20px; align-items: start; }
@media (min-width: 960px) {
  .two-col { grid-template-columns: minmax(320px, 400px) 1fr; }
  .two-col.wide-left { grid-template-columns: 1fr minmax(300px, 380px); }
  .sticky-col { position: sticky; top: 84px; }
}

.footer-about { margin-top: 8px; }
.sw-primary { background: var(--primary); }
.sw-tint { background: var(--tint); }
.sw-accent { background: var(--accent); }
.sw-bg { background: var(--bg); }

/* Khối có data-font riêng (ô xem trước) phải tự gán lại phông. */
[data-font] { font-family: var(--font-body); }
.font-sample b { font-family: var(--font-heading); font-weight: var(--heading-weight); }

/* ---------- Người dùng đã đăng nhập ---------- */
.user-menu { position: relative; }
.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}
.user-trigger::-webkit-details-marker { display: none; }
.user-trigger:hover,
.user-menu[open] .user-trigger { border-color: var(--primary); }
.user-trigger .icon { color: var(--text-muted); }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tint);
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 600;
  flex: none;
}
.user-name { font-weight: 500; font-size: 0.9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop { display: grid; gap: 4px; padding: 10px 0 0; }
.user-email { margin: 0 0 4px; padding: 0 12px; overflow-wrap: anywhere; }
@media (min-width: 1080px) {
  .user-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 50;
    width: 240px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-pop);
  }
  .user-email { padding: 0 4px; }
}

/* ---------- Hộp xin đồng ý trước khi đăng nhập ---------- */
.consent-dialog .check-list { margin: 8px 0 14px; gap: 8px; }
.consent-check { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--bg-soft); }

.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--on-primary); }
.account-actions { display: grid; gap: 14px; }
.account-actions p { margin: 6px 0 0; }
