/**
 * gn-search.css - Página de Pesquisa
 * Prefixo: ps-  (Page Search)
 * Carrega após gn-design-system.css
 */

:root {
  --ps-sidebar-w: 268px;
}

/* ═══════════════════════════════════════════════════════════════
   HERO
═══════════════════════════════════════════════════════════════ */
.ps-hero {
  background: linear-gradient(135deg, #111827 0%, #1C2B4A 65%, #1e3a5f 100%);
  padding-top: var(--gn-navbar-h, 64px);
  position: relative;
  overflow: hidden;
}
.ps-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 75% 50%, rgba(245,158,11,.09) 0%, transparent 58%);
  pointer-events: none;
}
.ps-hero__body {
  position: relative;
  padding: 2rem 0 2.5rem;
  max-width: 720px;
}
.ps-hero__kicker {
  font-size: .8125rem;
  color: rgba(255,255,255,.55);
  margin-bottom: .375rem;
  letter-spacing: .02em;
}
.ps-hero__kicker strong { color: #fff; font-weight: 700; }
.ps-hero__title {
  font-size: 1.625rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 1.375rem;
  line-height: 1.2;
}
.ps-hero__title em {
  font-style: normal;
  color: #F59E0B;
}

/* Barra de busca do hero */
.ps-search {
  display: flex;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 32px rgba(0,0,0,.32);
  max-width: 660px;
}
.ps-search__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  padding: .9375rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: #111827;
  background: transparent;
}
.ps-search__input::placeholder { color: #9ca3af; }
.ps-search__btn {
  background: #F59E0B;
  color: #111;
  border: none;
  padding: 0 1.625rem;
  font-size: .9375rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .5rem;
  transition: background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.ps-search__btn:hover { background: #D97706; }
.ps-search__btn i { font-size: .875rem; }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT 2 COLUNAS
═══════════════════════════════════════════════════════════════ */
.ps-page {
  padding: 2rem 0 4rem;
}
.ps-layout {
  display: grid;
  grid-template-columns: var(--ps-sidebar-w) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR - FILTROS (desktop)
═══════════════════════════════════════════════════════════════ */
.ps-sidebar {
  position: sticky;
  top: calc(var(--gn-navbar-h, 64px) + 1.25rem);
}
.ps-sidebar-card {
  background: #fff;
  border: 1.5px solid var(--gn-color-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: .875rem;
}
.ps-sidebar-card:last-child { margin-bottom: 0; }
.ps-sidebar-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--gn-color-border);
  background: var(--gn-gray-50);
}
.ps-sidebar-card__title {
  font-size: .875rem;
  font-weight: 700;
  color: var(--gn-gray-800);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.ps-sidebar-card__title i { color: var(--gn-color-primary); font-size: .8125rem; }
.ps-sidebar-card__body { padding: .875rem 1rem; }

/* Selects de filtro */
.ps-filter-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--gn-gray-50)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E")
    right .75rem center / 1rem no-repeat;
  border: 1.5px solid var(--gn-color-border);
  border-radius: 8px;
  padding: .5rem 2.5rem .5rem .75rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--gn-color-text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: block;
  margin-bottom: .625rem;
}
.ps-filter-select:last-of-type { margin-bottom: 0; }
.ps-filter-select:focus { outline: none; border-color: var(--gn-color-primary); }
.ps-filter-select.is-active {
  border-color: var(--gn-color-primary);
  background-color: var(--gn-primary-50);
  color: var(--gn-color-primary);
  font-weight: 600;
}

/* Botão limpar filtros */
.ps-clear-btn {
  width: 100%;
  padding: .5625rem 1rem;
  font-size: .8125rem;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  display: none;
  text-align: center;
}
.ps-clear-btn:hover { background: #fee2e2; }
.ps-clear-btn.is-visible { display: block; }

/* Tags de filtros ativos */
.ps-active-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--gn-color-border);
}
.ps-active-tags:empty { display: none; }
.ps-tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--gn-primary-50);
  color: var(--gn-color-primary);
  border: 1px solid var(--gn-primary-200);
  border-radius: 999px;
  padding: .25rem .625rem;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN - ÁREA DE RESULTADOS
═══════════════════════════════════════════════════════════════ */
.ps-results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.125rem;
  flex-wrap: wrap;
}
.ps-results-count {
  font-size: .9375rem;
  color: var(--gn-color-text-muted);
}
.ps-results-count strong { color: var(--gn-color-text); }

/* Botão "Filtros" - só mobile */
.ps-filter-toggle {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   PAGINAÇÃO - botões compatíveis com o JS existente
═══════════════════════════════════════════════════════════════ */
.gn-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding-block: var(--gn-space-8);
  flex-wrap: wrap;
}
.gn-page-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 .625rem;
  border: 1.5px solid var(--gn-color-border);
  background: #fff;
  border-radius: .5rem;
  font-size: .875rem;
  font-family: inherit;
  color: var(--gn-color-text);
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.gn-page-btn:hover:not(:disabled) {
  border-color: var(--gn-color-primary);
  color: var(--gn-color-primary);
  background: var(--gn-primary-50);
}
.gn-page-btn.is-active {
  background: var(--gn-color-primary);
  border-color: var(--gn-color-primary);
  color: #fff;
  font-weight: 700;
}
.gn-page-btn:disabled { opacity: .35; cursor: not-allowed; }
.gn-page-ellipsis {
  padding: 0 .25rem;
  color: var(--gn-gray-400);
  font-size: .875rem;
  line-height: 2.25rem;
}

/* ═══════════════════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════════════════ */
.gn-results-skeleton { display: none; }
.gn-results-skeleton.is-loading { display: grid; }
.gn-results-grid.is-loading { opacity: .35; pointer-events: none; }
.gn-skeleton-card {
  background: var(--gn-gray-100);
  border-radius: .75rem;
  height: 240px;
  animation: psSkeleton 1.5s ease-in-out infinite;
}
@keyframes psSkeleton {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

/* ═══════════════════════════════════════════════════════════════
   DESKTOP - oculta elementos exclusivos do drawer mobile
═══════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  /* O drawer header (título + botão fechar) não aparece no desktop */
  .ps-drawer-header { display: none; }

  /* ps-sidebar-inner é só um container transparente no desktop */
  .ps-sidebar-inner {
    background: transparent;
    border-radius: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
  }

  /* Tags de filtros ativos: sem borda inferior no desktop (visual inline) */
  .ps-active-tags {
    padding: 0;
    border: none;
    margin-bottom: .75rem;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO - TABLET (≤ 1024px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --ps-sidebar-w: 220px; }

  /* Grid de resultados: 2 colunas quando há sidebar */
  .ps-layout .gn-results-grid.gn-grid--3,
  .ps-layout .gn-results-skeleton.gn-grid--3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO - MOBILE (≤ 768px)
═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Hero compacto */
  .ps-hero__body { padding: 1.375rem 0 1.875rem; }
  .ps-hero__title { font-size: 1.25rem; margin-bottom: 1rem; }
  .ps-search { border-radius: 8px; }
  .ps-search__input { padding: .8125rem .875rem; font-size: .9375rem; }
  .ps-search__btn { padding: 0 1.125rem; font-size: .875rem; }

  /* Layout: 1 coluna */
  .ps-layout { grid-template-columns: 1fr; gap: 1rem; }
  .ps-page { padding: 1.25rem 0 3rem; }

  /* Sidebar vira drawer */
  .ps-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0,0,0,.55);
    top: 0;
    padding-top: 0;
    align-items: flex-end;
  }
  .ps-sidebar.is-open { display: flex; }

  .ps-sidebar-inner {
    background: #fff;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 82vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .ps-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.125rem .75rem;
    border-bottom: 1px solid var(--gn-color-border);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
  }
  .ps-drawer-header__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--gn-gray-900);
  }
  .ps-drawer-close {
    background: var(--gn-gray-100);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--gn-gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .ps-sidebar-card {
    border: none;
    border-radius: 0;
    border-bottom: 1px solid var(--gn-color-border);
    margin-bottom: 0;
  }
  .ps-sidebar-card:last-child { border-bottom: none; }
  .ps-sidebar-card__header { background: #fff; }

  /* Botão "Filtros" visível no mobile */
  .ps-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .875rem;
    background: #fff;
    border: 1.5px solid var(--gn-color-border);
    border-radius: 8px;
    font-size: .875rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    color: var(--gn-color-text);
    white-space: nowrap;
  }
  .ps-filter-badge {
    background: var(--gn-color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: .6875rem;
    font-weight: 700;
    padding: .1rem .45rem;
    display: none;
    line-height: 1.4;
  }
  .ps-filter-badge.is-visible { display: inline; }
}
