/* ====== BASIS ====== */
body.search-active { overflow: hidden; }

/* Mørkt overlay på PC/tablet når søgning er aktiv */
.search-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.search-overlay.active {
  display: block;
  opacity: 1;
}

/* JavaScript til at aktivere overlay når input får fokus */
.search-overlay {
  pointer-events: none;
}

.search-overlay.active {
  pointer-events: auto;
}

/* Container (bruges også på desktop) */
.page-search-offcanvas {
  position: relative;
  max-width: 800px;
  width: 100%;
  z-index: 101;
  background: transparent;
}

/* Når overlay er aktivt, giv hele søgecontaineren mørk baggrund (inkl. header) */
.search-overlay.active ~ .page-search-offcanvas,
.page-search-offcanvas.overlay-active {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Header */
.page-search-offcanvas .search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
}

/* Ikoner (tilbagepil + kryds udenfor input på mobil) */
.page-search-offcanvas .icon-back::before { content: '←'; font-size: 20px; }
.page-search-offcanvas .icon-clear::before { content: '×'; font-size: 22px; }

/* Mobil trigger bruger samme SVG som PC input */
.page-search-trigger {
  background-image: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" fill="%23666" viewBox="0 0 24 24">\
<path d="M10.5 3a7.5 7.5 0 015.996 12.093l4.206 4.206a1 1 0 01-1.414 1.414l-4.206-4.206A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z"/>\
</svg>');
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 16px 16px;
  padding-left: 40px;
}

/* Knapper (skjult som default) */
.page-search-offcanvas .back-btn {
  display: none;
  background: none;
  border: none;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 10px;
  color: #111;
  box-shadow: none;
}
.page-search-offcanvas .back-btn:hover { background: #f3f3f3; }

/* Input wrap */
.page-search-offcanvas .search-input-wrap {
  position: relative;
  flex: 1;
}

/* Input felt */
#page-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 48px 12px 48px; /* Øget padding for større størrelse */
  font-size: 16px; /* Større skrift */
  border: 1px solid #ccc;
  border-radius: 100px;
  background-color: #fff;
  background-image: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" fill="%23666" viewBox="0 0 24 24">\
<path d="M10.5 3a7.5 7.5 0 015.996 12.093l4.206 4.206a1 1 0 01-1.414 1.414l-4.206-4.206A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z"/>\
</svg>');
  background-repeat: no-repeat;
  background-position: 16px center; /* Justeret position for større padding */
  background-size: 18px 18px; /* Større søgeikon */
}

/* Clear-ikon inde i input */
.clear-inside {
  position: absolute !important;
  right: 12px !important;
  top: 45% !important;
  transform: translateY(-50%) !important;
  width: auto !important;
  height: auto !important;
  border: 0 !important;
  background: transparent !important;
  border-radius: 24px !important;
  font-size: 32px !important;
  line-height: 1 !important;
  color: #666 !important;
  cursor: pointer !important;
  display: none; /* skjult som udgangspunkt */
  box-sizing: border-box !important;
  padding: 0 !important;
  margin: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  transition: color 0.2s ease !important;
  box-shadow: none;
}

.clear-inside:hover {
  color: #333 !important;
}

/* Vis clear ikon kun når input har værdi */
#page-search-input:not(:placeholder-shown) ~ .clear-inside,
.search-input-wrap.has-value .clear-inside {
  display: flex !important;
}


/* Skjul det oprindelige browser clear ikon helt */
#page-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none !important;
}

/* Vis kryds når input ikke er tomt */
#page-search-input:not(:placeholder-shown) ~ .clear-inside {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search-input-wrap.has-value .clear-inside {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Dropdown liste (desktop) */
.page-search-offcanvas .autocomplete-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 12px;
  list-style: none;
  margin: 0; padding: 0;
  max-height: 400px;
  overflow-y: auto;
  z-index: 101;
}
.page-search-offcanvas .autocomplete-suggestions.show-suggestions { display: block; }
.page-search-offcanvas .autocomplete-suggestions li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}
.page-search-offcanvas .autocomplete-suggestions li:last-child { border-bottom: none; }
.page-search-offcanvas .autocomplete-suggestions li:hover,
.page-search-offcanvas .autocomplete-suggestions li.active { background: #f5f5f5; }
.page-search-offcanvas .autocomplete-suggestions li img {
  width: 64px; height: 64px; border-radius: 8px; object-fit: cover;
}
.page-search-offcanvas .autocomplete-suggestions li .no-thumb {
  width: 64px; height: 64px; border-radius: 8px; background: #ddd;
}
.page-search-offcanvas .autocomplete-suggestions li .text-wrap { flex: 1; }
.page-search-offcanvas .autocomplete-suggestions li .title {
  font-size: 14px; font-weight: 600; color: #222;
}
.autocomplete-suggestions li .suggestion-link {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit; width: 100%;
}
.page-search-offcanvas .autocomplete-suggestions .no-results {
  padding: 12px; color: #666; cursor: default;
}

/* Mobil trigger (synlig KUN på mobil) */
.page-search-trigger {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  padding-left: 40px;
  border: 1px solid #ccc;
  border-radius: 100px;
  background: #fff;
  background-image: url('data:image/svg+xml;utf8,\
<svg xmlns="http://www.w3.org/2000/svg" fill="%23666" viewBox="0 0 24 24">\
<path d="M10.5 3a7.5 7.5 0 015.996 12.093l4.206 4.206a1 1 0 01-1.414 1.414l-4.206-4.206A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z"/>\
</svg>');
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 16px 16px;
  cursor: pointer;
  font-size: 14px;
}

/* Skjul emoji i mobil trigger */
.page-search-trigger::before {
  content: "" !important;
}
.page-search-trigger .trigger-text { color: #444; }

/* ====== MOBIL OFF-CANVAS ====== */
@media (max-width: 768px) {
  .page-search-trigger { display: inline-flex; }
  
  /* Skjul overlay på mobil */
  .search-overlay {
    display: none !important;
  }

  .page-search-offcanvas {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
  }
  .page-search-offcanvas.active { transform: translateX(0); }

  .page-search-offcanvas .search-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 201;
  }

  /* Vis tilbageknap kun på mobil */
  .page-search-offcanvas.active .back-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Resultater fylder resten og scroller */
  .page-search-offcanvas .autocomplete-suggestions {
    position: relative;
    top: 0;
    border: none;
    border-radius: 0;
    flex: 1;
    max-height: none;
    overflow-y: auto;
    margin: 0;
    -webkit-overflow-scrolling: touch;
  }
}