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

   Two layouts:
     - .cpt-layout-horizontal → 2-col grid, logo left + content right
     - .cpt-layout-vertical   → 3-col grid, image top + content below
   ============================================ */

/* ── 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;
}

.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 */
.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 "All" button */
.cpt-filter-tag:not([style*="--tag-color"]):hover {
  border-color: #c4b5fd;
  color: #7c3aed;
  background: #f5f3ff;
}

/* ── LOADING STATE ───────────────────── */
.cpt-filter-results.is-loading {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================
   LAYOUT: HORIZONTAL (default)
   2 columns, logo left + content right
   ============================================ */
.cpt-layout-horizontal .cpt-filter-results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  transition: opacity 0.25s ease;
}

.cpt-filter-card--horizontal {
  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--horizontal:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.07);
}

/* Horizontal — image (left side) */
.cpt-filter-card--horizontal .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--horizontal .cpt-filter-card__image img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

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

/* Horizontal — content (right side) */
.cpt-filter-card--horizontal .cpt-filter-card__content {
  flex: 1;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

/* Horizontal — date hidden by default */
.cpt-filter-card--horizontal .cpt-filter-card__date {
  display: none;
}

/* ============================================
   LAYOUT: VERTICAL
   3 columns, image top + content below
   ============================================ */
.cpt-layout-vertical .cpt-filter-results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  transition: opacity 0.25s ease;
}

.cpt-filter-card--vertical {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #eef0f4;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cpt-filter-card--vertical:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Vertical — image (top) */
.cpt-filter-card__image--vertical {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #e5e7eb;
}

.cpt-filter-card__image--vertical img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cpt-filter-card__placeholder--vertical {
  width: 100%;
  height: 100%;
  background: #dfe2e8;
}

/* Vertical — content (below image) — flex to push entity to bottom */
.cpt-filter-card--vertical .cpt-filter-card__content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Vertical — date visible */
.cpt-filter-card__date--visible {
  display: block !important;
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.4rem;
}

/* Vertical — Entity section (logo + name + date at card bottom) */
.cpt-filter-card__entity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid #f0f1f4;
}

.cpt-filter-card__entity-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
}

.cpt-filter-card__entity-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cpt-filter-card__entity-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}

.cpt-filter-card__entity-date {
  font-size: 0.75rem;
  color: #9ca3af;
  line-height: 1.3;
}

/* ── SHARED CARD ELEMENTS ────────────── */

/* Title */
.cpt-filter-card__title {
  font-size: 1.1rem;
  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;
}

/* Tags inside cards */
.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);
}

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

/* Date (hidden by default, shown with --visible modifier) */
.cpt-filter-card__date {
  display: none;
}

/* ── PAGINATION ──────────────────────── */
.cpt-filter-pagination {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

.cpt-pagination-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cpt-page-btn {
  padding: 0.5rem 0.85rem;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  background: #fff;
  color: #4b5563;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.cpt-page-btn:hover {
  background: #f5f3ff;
  border-color: #c4b5fd;
  color: #7c3aed;
}

.cpt-page-btn.cpt-page-active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
  font-weight: 600;
}

.cpt-page-prev,
.cpt-page-next {
  font-weight: 600;
}

/* ── 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 ──────────────────────── */

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

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

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

/* Vertical layout */
@media (max-width: 992px) {
  .cpt-layout-vertical .cpt-filter-results {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .cpt-layout-vertical .cpt-filter-results {
    grid-template-columns: 1fr;
  }
}

/* Shared responsive */
@media (max-width: 600px) {
  .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;
  }

  .cpt-pagination-inner {
    flex-wrap: wrap;
    justify-content: center;
  }
}