/* ==============================================================================
   BUSCADOR GENERAL DEL LLOC WEB (GLOBAL SEARCH WIDGET)
   Disseny fidel al web original de l'Institut: panell blau vibrant amb targetes blanques
   ============================================================================== */

/* Botó de cerca al menú de navegació d'escriptori */
.nav-search-item {
  display: flex;
  align-items: center;
  margin-left: 6px;
}

.nav-search-btn {
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--primary, #146d99);
  cursor: pointer;
  padding: 7px 9px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
}

.nav-search-btn:hover {
  background: rgba(20, 109, 153, 0.08);
  color: var(--primary-dark, #093e58);
  transform: scale(1.06);
}

.nav-search-btn svg {
  width: 19px;
  height: 19px;
  display: block;
}

/* Botó de cerca per a capçalera mòbil */
.nav-search-btn-mobile {
  background: transparent;
  border: none;
  color: var(--primary, #146d99);
  cursor: pointer;
  padding: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-right: 4px;
}

.nav-search-btn-mobile:hover {
  background: rgba(20, 109, 153, 0.08);
}

.nav-search-btn-mobile svg {
  width: 22px;
  height: 22px;
  display: block;
}

@media (max-width: 991px) {
  .nav-search-btn-mobile {
    display: inline-flex;
  }
  .nav-search-item {
    display: none;
  }
}

/* Teló de fons (Backdrop) */
.site-search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 29, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99990;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.site-search-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Panell de cerca (Modal blau) */
.site-search-panel {
  position: fixed;
  top: 75px;
  right: 24px;
  width: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 95px);
  background: #146d99;
  background: linear-gradient(175deg, #167bb0 0%, #0d5477 100%);
  color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  z-index: 99995;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.site-search-panel *,
.site-search-panel *::before,
.site-search-panel *::after {
  box-sizing: border-box;
}

.site-search-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Fila superior amb input i botó de tancar */
.site-search-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.site-search-close-modal-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  padding: 0;
}

.site-search-close-modal-btn:hover {
  background: #ffffff;
  color: #146d99;
  border-color: #ffffff;
  transform: scale(1.05);
}

.site-search-close-modal-btn svg {
  display: block;
}

/* Caixa d'entrada de cerca */
.site-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  padding: 4px 12px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.site-search-input-wrap:focus-within {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.site-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 4px;
  font-family: inherit;
}

.site-search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

.site-search-clear-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-right: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-search-clear-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.site-search-icon-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-search-icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Comptador de resultats (estil fidel a la captura) */
.site-search-count {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 16px 0 12px 2px;
  line-height: 1.3;
}

.site-search-count mark {
  background: transparent;
  color: #fef08a;
  font-weight: 900;
  text-decoration: underline;
}

/* Llista de resultats amb scroll vertical */
.site-search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 58vh;
  padding-right: 6px;
}

.site-search-results::-webkit-scrollbar {
  width: 6px;
}
.site-search-results::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
.site-search-results::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}
.site-search-results::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Targeta de resultat individual (blanca sobre fons blau) */
.site-search-card {
  background: #ffffff;
  color: #1e293b;
  border-radius: 8px;
  padding: 14px 18px;
  text-decoration: none;
  display: block;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.site-search-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
  border-color: #38bdf8;
}

.site-search-card-cat {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0369a1;
  margin-bottom: 5px;
}

.site-search-card-cat.cat-serveis { background: #dcfce7; color: #15803d; }
.site-search-card-cat.cat-divulgació { background: #fef3c7; color: #b45309; }
.site-search-card-cat.cat-media { background: #f3e8ff; color: #7e22ce; }
.site-search-card-cat.cat-testimonis { background: #ffe4e6; color: #be123c; }
.site-search-card-cat.cat-faq { background: #e0e7ff; color: #4338ca; }

.site-search-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #146d99;
  text-transform: uppercase;
  line-height: 1.35;
  margin: 0 0 4px 0;
}

.site-search-card-desc {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.45;
  margin: 0;
}

.site-search-card mark {
  background: #fef08a;
  color: #713f12;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 2px;
}

/* Estat buit o suggeriments */
.site-search-empty {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  color: #e2e8f0;
  font-size: 0.9rem;
}

.site-search-suggs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.site-search-sugg-tag {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.site-search-sugg-tag:hover {
  background: #ffffff;
  color: #146d99;
}

/* Responsivitat per a mòbils */
@media (max-width: 768px) {
  .site-search-panel {
    top: 60px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 72px);
    padding: 16px 14px;
    border-radius: 12px;
  }
  .site-search-input {
    font-size: 1rem;
    padding: 6px 2px;
  }
  .site-search-count {
    font-size: 0.88rem;
    margin: 12px 0 10px 2px;
  }
  .site-search-card {
    padding: 12px 14px;
  }
  .site-search-card-title {
    font-size: 0.88rem;
  }
  .site-search-card-desc {
    font-size: 0.78rem;
  }
}

