/* ============================================
   CPT Ajax Filter & Search v2.0.0
   Author: Rolando Escobar

   Layout: Horizontal cards (logo left + content right)
   Grid:   2 columns
   Tags:   Color-coded via CSS custom properties
   ============================================ */

/* -- WRAPPER -- */
.cpt-filter-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── SEARCH BAR ──────────────────────── */
.cpt-filter-search-bar {
  position: relative;
  max-width: 700px;
  margin: 0 auto 1.5rem;
}

.cpt-filter-search-input {
  width: 100%;
  padding: 0.875rem 3rem 0.875rem 1.25rem;
  border: 1px solid #e2e5ea;
  border-radius: 12px;
  font-size: 1rem;
  color: #1f2937;
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.cpt-filter-search-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.cpt-filter-search-input::placeholder {
  color: #9ca3af;
}

.cpt-filter-search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

/* ── FILTER TAGS (top bar) ───────────── */
.cpt-filter-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

/* Base filter button style */
.cpt-filter-tag {
  padding: 0.4rem 1.1rem;
  border: 1.5px solid #e2e5ea;
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

/* Color-coded filter buttons using --tag-color from PHP */
.cpt-filter-tag[style*="--tag-color"] {
  color: var(--tag-color);
  border-color: color-mix(in srgb, var(--tag-color) 35%, #e2e5ea);
}

.cpt-filter-tag[style*="--tag-color"]:hover {
  background: color-mix(in srgb, var(--tag-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--tag-color) 60%, transparent);
}

/* Active state */
.cpt-filter-tag.active {
  background: #f5f3ff;
  border-color: #8b5cf6;
  color: #7c3aed;
  font-weight: 600;
}

.cpt-filter-tag[style*="--tag-color"].active {
  background: color-mix(in srgb, var(--tag-color) 12%, #fff);
  border-color: var(--tag-color);
  color: var(--tag-color);
  font-weight: 600;
}

/* Default hover for the "All" button (no --tag-color) */
.cpt-filter-tag:not([style*="--tag-color"]):hover {
  border-color: #c4b5fd;
  color: #7c3aed;
  background: #f5f3ff;
}

/* ── RESULTS GRID — 2 columns ────────── */
.cpt-filter-results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  transition: opacity 0.25s ease;
}

.cpt-filter-results.is-loading {
  opacity: 0.4;
  pointer-events: none;
}

/* ── CARD — Horizontal layout ────────── */
.cpt-filter-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: #f8f9fc;
  border: 1px solid #eef0f4;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cpt-filter-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
}

/* Card Image — left side (logo / thumbnail) */
.cpt-filter-card__image {
  flex: 0 0 120px;
  width: 120px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef1f6;
  overflow: hidden;
  padding: 0.75rem;
}

.cpt-filter-card__image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.cpt-filter-card__placeholder {
  width: 64px;
  height: 64px;
  background: #dfe2e8;
  border-radius: 12px;
}

/* Card Content — right side */
.cpt-filter-card__content {
  flex: 1;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0; /* Allow text wrapping */
}

/* Card Title */
.cpt-filter-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.45rem 0;
  line-height: 1.3;
}

.cpt-filter-card__title a {
  color: inherit;
  text-decoration: none;
}

.cpt-filter-card__title a:hover {
  color: #7c3aed;
}

/* Card Tags — below title, color-coded */
.cpt-filter-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.cpt-filter-card__tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--tag-color, #6b7280);
  background: color-mix(in srgb, var(--tag-color, #6b7280) 12%, transparent);
}

/* Card Date — hidden by default in this layout */
.cpt-filter-card__date {
  display: none;
  /* To show the date, change to:
     display: block;
     font-size: 0.75rem;
     color: #9ca3af;
     margin-bottom: 0.3rem;
  */
}

/* Card Excerpt */
.cpt-filter-card__excerpt {
  font-size: 0.825rem;
  color: #6b7280;
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── LOADER / SPINNER ────────────────── */
.cpt-filter-loader {
  display: flex;
  justify-content: center;
  padding: 2rem;
}

.cpt-filter-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: cpt-spin 0.7s linear infinite;
}

@keyframes cpt-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── NO RESULTS ──────────────────────── */
.cpt-filter-no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: #9ca3af;
  font-size: 1rem;
  padding: 3rem 1rem;
}

/* ── RESPONSIVE ──────────────────────── */
@media (max-width: 768px) {
  .cpt-filter-results {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .cpt-filter-card {
    flex-direction: column;
  }

  .cpt-filter-card__image {
    flex: none;
    width: 100%;
    min-height: 80px;
    max-height: 120px;
  }

  .cpt-filter-search-bar {
    max-width: 100%;
  }

  .cpt-filter-tags {
    gap: 0.35rem;
  }

  .cpt-filter-tag {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
  }
}
