/**
 * Filter System Styles
 * Sistema de filtros com categorias hierárquicas até 3 níveis
 * Usado em: page-asp-filter-tags.php
 */

/* Toggle arrow para subcategorias */
.toggle-subcats {
  display: inline-block;
  cursor: pointer;
  margin-left: 8px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid #333;
  transition: transform 0.2s ease;
  user-select: none;
}

.toggle-subcats.expanded {
  transform: rotate(180deg);
}

/* Container de subcategorias - fechado por padrão */
.subcategories,
.sub-level-items {
  display: none;
  transition: all 0.3s ease;
  overflow: hidden;
}

.subcategories.open,
.sub-level-items.open {
  display: block;
}

/* Wrapper para alinhar label e toggle */
.filtro-item-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
}

.filtro-item-wrapper label {
  flex: 1;
  display: flex;
  align-items: baseline;
  margin: 0;
}

.filtro-item-wrapper input[type='checkbox'] {
  margin-right: 8px;
  flex-shrink: 0;
}

/* Hover effect no label das categorias */
.cat-label {
  line-height: 1.4;
}

.cat-label:hover {
  opacity: 0.7;
}

.cat-label.has-children {
  cursor: pointer;
}

/* Layout das categorias parent */
.parent-category {
  display: block;
  margin-bottom: 8px;
}

.parent-category .filtro-item-wrapper {
  display: flex;
  align-items: center;
}

/* Subcategorias indentadas por nível */
.filtro-item.subcategory {
  margin-left: 0;
  margin-bottom: 6px;
}

.filtro-item.subcategory.level-2 {
  padding-left: 25px;
}

.filtro-item.subcategory.level-3 {
  padding-left: 25px;
}

.filtro-item.subcategory .filtro-item-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
}

/* Remove list style from emodules pages list */
#emodules-pages-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* 2-column grid scoped to emodules section */
.emodules-pages-section #list-pages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media screen and (max-width: 640px) {
  .emodules-pages-section #list-pages {
    grid-template-columns: 1fr;
  }
}

/* Page item with thumbnail layout */
.filters-option.item-page {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  flex-direction: column;
}

.page-thumbnail {
  flex-shrink: 0;
}

.page-thumb-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  display: block;
}

.page-content-wrapper {
  flex: 1;
}

.page-excerpt {
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #666;
}

/* Search Result Tags - Links Clicáveis */
.search-result__tags {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

/* Emodule card layout */
.emodules-pages-section .search-result {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.emodules-pages-section .search-result__inner {
  flex: 1;
}

.emodule-teaser-desc {
  font-size: 14px;
  line-height: 1.5;
  margin: 10px 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-result__desc_actions {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.search-result__desc {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-dark);
}

.emodule-lang,
.emodule-ce,
.emodule-cost {
  padding: 2px 8px;
  border-radius: 4px;
  background-color: #ffffff;
  border: 1px solid #ffffff;
  white-space: nowrap;
  color: var(--color-dark);
}

.emodules-pages-section .search-result__actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}

/* Tags como texto simples */
.search-result__tags-text {
  font-size: 13px;
  color: #666;
  font-style: italic;
  margin: 8px 0;
}

.search-result__tag-link,
.search-result__cat-link {
  display: inline-block;
  padding: 2px 8px;
  background-color: #f0f0f0;
  color: #333;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #e0e0e0;
}
/* Esconder temporariamente os links de tags (post_tag) */
.search-result__tag-link {
  display: none !important;
}
.search-result__tag-link:hover,
.search-result__cat-link:hover {
  background-color: #e0e0e0;
  border-color: #d0d0d0;
  text-decoration: none;
}

.search-result__tag-link.active,
.search-result__cat-link.active {
  background-color: var(--color-dark);
  color: #fff;
}

/* Filter Loading Indicator */
.filter-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.filter-loading__spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007bff;
  border-radius: 50%;
  animation: filter-spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes filter-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.filter-loading p {
  font-size: 16px;
  color: #666;
  margin: 0;
}

/* ── Emodule Icon Grid ───────────────────────────────────────────────────── */
.emodule-icon-section .icon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.emodule-icon-section .icon-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 8px;
  /* 4 columns on desktop */
  flex: 0 0 calc(25% - 1rem);
  max-width: calc(25% - 1rem);
  border-radius: 25px;
}

.emodule-icon-section .icon-grid-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.emodule-icon-section .icon-grid-name {
  font-weight: 700;
  word-break: break-word;
  color: white;
}

/* ── Emodule Single — Title row (badge + title side-by-side) ────────────── */
.emodule-single-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.emodule-single-icon-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  flex-shrink: 0;
  min-width: 64px;
  max-width: 80px;
  text-align: center;
}

/* ── Emodule Card — badge beside thumbnail ───────────────────────────────── */
.search-result__thumb-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.search-result__thumb-wrap .emodule-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 10px;
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  text-align: center;
}

.search-result__thumb-wrap .emodule-badge-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.search-result__thumb-wrap .emodule-badge-name {
  font-size: 0.58rem;
}

.search-result__thumb {
  flex: 1;
  min-width: 0;
}

.emodule-badge-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  display: block;
}

.emodule-badge-name {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  word-break: break-word;
  line-height: 1.2;
  color: white;
}

/* ── Credits Stamp ──────────────────────────────────────────────────────── */

.credits-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 64px;
  height: 64px;
  background-color: #e431a5;
  color: #ffffff;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.2;
  border-radius: 50%;
  position: relative;
}

.credits-stamp small {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* ── Emodule Single Meta Strip ──────────────────────────────────────────── */
.emodule-single-meta {
  margin-top: 20px;
  gap: 8px;
}

.emodule-single-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.emodule-single-meta-item .meta-label {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.emodule-single-meta-item .meta-value {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: #ffffff;
  border: 1px solid #ffffff;
  white-space: nowrap;
  color: var(--color-dark);
}

/* ── Emodule Single Image ────────────────────────────────────────────────── */
.emodule-single-image {
  display: flex;
}

.emodule-single-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 25px;
  display: block;
}

/* ── Emodule Credits Blocks — webinar dual-block layout ────────────────── */
.emodule-credits-blocks {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.emodule-webinar-block {
  flex: 1 1 280px;
}

@media screen and (max-width: 639px) {
  .emodule-single-image {
    margin-bottom: 20px;
  }
}

/* ── Icon grid — mobile overrides ───────────────────────────────────────── */
@media screen and (max-width: 639px) {
  .emodule-icon-section .icon-grid-item {
    flex: 0 0 calc(50% - 1rem);
    max-width: calc(50% - 1rem);
  }

  .emodule-icon-section .icon-grid-img {
    width: 70px;
    height: 70px;
  }
}

/* ── Column filter — mobile dark background ──────────────────────────────── */
@media screen and (max-width: 639px) {
  .column-filter {
    background: var(--color-dark, #111827) !important;
  }

  .column-filter,
  .column-filter h3,
  .column-filter label,
  .column-filter span,
  .column-filter .filtro-item {
    color: #ffffff !important;
  }

  .column-filter .filter-categories-header h3 {
    color: #ffffff !important;
  }

  .column-filter .filter-toggle-icon::before,
  .column-filter .filter-toggle-icon::after {
    background-color: #ffffff;
  }
}

/* ── Filter categories toggle (mobile) ──────────────────────────────────── */
.filter-categories-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Badge filter labels ────────────────────────────────────────────────── */
.filtro-badge-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.filtro-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.filtro-badge-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
}

.filter-toggle-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.filter-toggle-icon {
  display: block;
  width: 22px;
  height: 22px;
  position: relative;
}

.filter-toggle-icon::before,
.filter-toggle-icon::after {
  content: '';
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--color-dark, #333);
  border-radius: 2px;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease;
}

/* horizontal bar */
.filter-toggle-icon::before {
  width: 16px;
  height: 2px;
}

/* vertical bar (makes a + sign; rotates to – when open) */
.filter-toggle-icon::after {
  width: 2px;
  height: 16px;
}

/* When open, vertical bar disappears → becomes a minus/close */
.filter-toggle-btn[aria-expanded='true'] .filter-toggle-icon::after {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

@media screen and (max-width: 639px) {
  .filter-toggle-btn {
    display: block;
  }

  /* hidden by default on mobile until JS initialises */
  .list-filter.filter-collapsed {
    display: none;
  }
}
