/*
 * RIAV — Catalog (Danh mục bản ghi) styles.
 *
 * Extends site.css components without overriding them.
 * Loaded only on the page-templates/template-danh-muc.php page template.
 */

/* ---- Sticky search bar -------------------------------------------------- */

.search-bar {
  position: sticky;
  top: 72px; /* clears the 72px .site-header */
  z-index: 30;
  background: var(--neutral-50);
  border-bottom: 1px solid var(--neutral-100);
  padding-block: 16px;
}

.search-bar__row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .search-bar__row {
    grid-template-columns: 1.6fr 1fr 1fr 1fr auto;
    align-items: end;
  }

  /* Single-keyword variant: one wide search field + the action buttons. */
  .search-bar__row--simple {
    grid-template-columns: 1fr auto;
  }
}

/* Search + Reset buttons sit on the same baseline as the input box.
   align-items:end on the row bottom-aligns this group with the input; matching
   min-height makes the "Tìm" button the same size as the input (not floating). */
.search-bar__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-bar__actions .btn--primary {
  min-height: 52px;
}

/* On the simple bar, the search input has no top label gap to fight with, so
   keep the button row flush to the input's full height. */
.search-bar__row--simple .field {
  justify-content: flex-end;
}

/* ---- Results head -------------------------------------------------------- */

.results-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 32px 0 16px;
}

.results-head .count {
  font-size: 14px;
  color: var(--neutral-500);
}

.results-head .count strong {
  color: var(--neutral-900);
  font-weight: 600;
}

/* ---- View toggle --------------------------------------------------------- */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle button {
  background: white;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--neutral-500);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--t), color var(--t);
}

.view-toggle button[aria-pressed="true"] {
  background: var(--brand-primary);
  color: white;
}

.view-toggle button + button {
  border-left: 1px solid var(--neutral-200);
}

/* ---- JS-driven visibility (catalog.js toggles the [hidden] attribute) ---- */
/* These elements carry their own display values, so [hidden] alone (UA rule)
   would be overridden — force the hide here. */
.results[hidden],
.pager-row[hidden],
.empty[hidden],
.catalog-loading[hidden] { display: none; }

/* ---- Loading state ------------------------------------------------------- */

.catalog-loading {
  margin: 24px 0;
  padding: 40px 24px;
  text-align: center;
  color: var(--neutral-500);
  font-size: 14px;
  background: white;
  border: 1px dashed var(--neutral-200);
  border-radius: var(--radius);
}

/* ---- Results: table / card visibility ----------------------------------- */

.results.is-cards table   { display: none; }
.results .cards           { display: none; }
.results.is-cards .cards  { display: grid; gap: 12px; }

/* ---- Table sort indicators ---------------------------------------------- */

.results table th.sortable {
  cursor: pointer;
  user-select: none;
}

.results table th.sortable::after {
  content: "↕";
  margin-left: 6px;
  color: var(--neutral-300);
  font-size: 11px;
}

.results table th.sortable[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--brand-primary);
}

.results table th.sortable[aria-sort="descending"]::after {
  content: "↓";
  color: var(--brand-primary);
}

/* ---- Table cell helpers -------------------------------------------------- */

td.song {
  font-weight: 600;
  color: var(--neutral-900);
}

td.song a {
  color: inherit;
}

td.song a:hover {
  color: var(--brand-accent-700);
}

td.year {
  font-variant-numeric: tabular-nums;
  color: var(--neutral-500);
}

td.action {
  text-align: right;
}

/* ---- Contact icon button ------------------------------------------------- */

.iconbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--t);
  white-space: nowrap;
}

.iconbtn:hover {
  background: var(--brand-accent);
  color: var(--brand-primary);
}

.iconbtn .ico {
  width: 14px;
  height: 14px;
}

/* ---- Mobile card view ---------------------------------------------------- */

.card-row {
  background: white;
  border: 1px solid var(--neutral-100);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}

.card-row .top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.card-row .song {
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-900);
}

.card-row .song a {
  color: inherit;
}

.card-row .song a:hover {
  color: var(--brand-accent-700);
}

.card-row .meta {
  font-size: 13px;
  color: var(--neutral-500);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}

.card-row .meta dt {
  font-weight: 500;
  color: var(--neutral-700);
}

.card-row .actions {
  margin-top: 8px;
}

/* ---- Empty state --------------------------------------------------------- */

.empty {
  background: white;
  border: 1px dashed var(--neutral-200);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--neutral-500);
}

.empty .ico-circle {
  margin: 0 auto 16px;
  background: var(--neutral-100);
  color: var(--neutral-500);
}

.empty h3 {
  color: var(--neutral-900);
  font-size: 18px;
  margin-bottom: 8px;
}

.empty p {
  font-size: 14px;
  max-width: 420px;
  margin-inline: auto;
}

/* ---- Skeleton shimmer (shown while JS hydrates cards) ------------------- */

.skeleton-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1.2fr 80px 100px;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--neutral-100);
}

.skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--neutral-100) 0%,
    #e3e8f0 50%,
    var(--neutral-100) 100%
  );
  background-size: 200% 100%;
  animation: riav-shimmer 1.4s linear infinite;
}

@keyframes riav-shimmer {
  from { background-position:  200% 0; }
  to   { background-position: -200% 0; }
}

/* ---- Active filter chips ------------------------------------------------- */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Hide chips container when it contains no children (JS fallback) */
.chips:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--brand-accent-soft);
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 500;
}

/* chip-remove is an <a> in the server-rendered version */
.chip-remove,
.chip button.chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.chip-remove:hover,
.chip button.chip-remove:hover {
  color: var(--brand-accent-700);
}

/* ---- Reset button variant ------------------------------------------------ */

.btn--text {
  background: none;
  border: none;
  color: var(--neutral-500);
  font: inherit;
  cursor: pointer;
  padding: 12px 8px;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 14px;
  transition: color var(--t);
}

.btn--text:hover {
  color: var(--brand-primary);
}

/* ---- Pagination row ------------------------------------------------------ */

.pager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  flex-wrap: wrap;
  gap: 12px;
}

.pager-row .meta {
  font-size: 13px;
  color: var(--neutral-500);
}

/* WP paginate_links outputs plain <a> and <span> elements inside .pagination */
.pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding-inline: 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-700);
  border: 1px solid var(--neutral-200);
  background: white;
  transition: background var(--t), color var(--t), border-color var(--t);
}

.pagination a:hover {
  background: var(--neutral-100);
  color: var(--brand-primary);
  border-color: var(--neutral-300);
}

.pagination .current,
.pagination a[aria-current="page"] {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

.pagination .dots,
.pagination .page-numbers.dots {
  border: none;
  background: none;
  color: var(--neutral-500);
}

/* ---- Visually hidden helper (for table caption) ------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
