/* ============================================================
   Byggetjek Design System — Flat, moderne, nordisk
   Alle farver i HSL. Standalone CSS (ingen Tailwind).
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---- CSS Custom Properties (scoped to search component) ---- */
.search-wrapper {
  --background:        hsl(0, 0%, 100%);
  --foreground:        hsl(220, 39%, 11%);     /* Gray 900 #111827 */

  --card:              hsl(0, 0%, 100%);
  --card-foreground:   hsl(220, 39%, 11%);

  --popover:           hsl(0, 0%, 100%);
  --popover-foreground:hsl(220, 39%, 11%);

  /* Brand Blue 700 #1A56DB */
  --primary:           hsl(222, 79%, 48%);
  --primary-foreground:hsl(0, 0%, 100%);
  --primary-hover:     hsl(222, 81%, 40%);
  --primary-soft:      hsl(222, 100%, 96%);    /* Brand Blue 100 #EBF1FF */
  --primary-subtle:    hsl(222, 100%, 98%);

  /* Success Green */
  --success:           hsl(160, 94%, 30%);
  --success-foreground:hsl(0, 0%, 100%);
  --success-soft:      hsl(152, 81%, 96%);

  /* Neutrals */
  --secondary:         hsl(220, 14%, 96%);     /* Gray 50 #F9FAFB */
  --secondary-foreground: hsl(220, 39%, 11%);
  --muted:             hsl(220, 14%, 96%);
  --muted-foreground:  hsl(220, 9%, 46%);      /* Gray 500 #6B7280 */
  --border:            hsl(220, 13%, 91%);     /* Gray 200 #E5E7EB */
  --body:              hsl(220, 18%, 27%);     /* Gray 700 #374151 */

  --radius:            0.625rem;

  /* Shadows */
  --shadow-card:       0 1px 2px 0 hsl(220 39% 11% / 0.04), 0 1px 3px 0 hsl(220 39% 11% / 0.06);
  --shadow-card-hover: 0 4px 6px -1px hsl(220 39% 11% / 0.08), 0 10px 20px -5px hsl(222 79% 48% / 0.10);

  --transition-base:   all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  position: relative;
  z-index: 50;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   SEARCH INPUT BOX
   ============================================================ */
.search-box {
  position: relative;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-card-hover);
  transition: var(--transition-base);
}

.search-box.is-open,
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsl(222 79% 48% / 0.15), var(--shadow-card-hover);
}

/* Search icon (left) */
.search-box__icon {
  pointer-events: none;
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

/* The actual <input> */
.search-box__input {
  height: 4rem;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding-left: 3.5rem;
  padding-right: 8rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--foreground);
  border-radius: 1rem;
}

.search-box__input::placeholder {
  color: var(--muted-foreground);
}

/* Right side: clear button + kbd hint */
.search-box__right {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Clear (×) button */
.search-box__clear {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 9999px;
  padding: 0.375rem;
  color: var(--muted-foreground);
  transition: var(--transition-base);
}

.search-box__clear:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.search-box__clear svg {
  width: 1rem;
  height: 1rem;
}

/* Keyboard shortcut badge */
.search-box__kbd {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--secondary);
  padding: 0.25rem 0.5rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted-foreground);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .search-box__kbd {
    display: none;
  }
}

/* ============================================================
   DROPDOWN
   ============================================================ */
.search-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 100;
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  background: var(--popover);
  box-shadow: 0 20px 60px -10px hsl(220 39% 11% / 0.18), 0 4px 16px -4px hsl(222 79% 48% / 0.12);
}

.search-dropdown.is-visible {
  display: block;
}

/* ---- Dropdown section header ---- */
.search-group__header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
}

.search-group__header.is-highlight {
  color: var(--primary);
}

.search-group {
  /* no extra styling needed */
}

.search-group.is-highlight {
  background: hsl(222 100% 96% / 0.3);
}

.search-group__items {
  padding-bottom: 0.25rem;
}

/* ---- Individual result row ---- */
.search-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s ease;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}

.search-item:hover,
.search-item.is-active {
  background: var(--primary-soft);
}

/* Icon bubble */
.search-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 0.5rem;
  background: var(--primary-soft);
  color: var(--primary);
}

.search-item__icon.is-highlight {
  background: var(--primary);
  color: var(--primary-foreground);
}

.search-item__icon svg {
  width: 1rem;
  height: 1rem;
}

/* Text block */
.search-item__body {
  min-width: 0;
  flex: 1;
}

.search-item__title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-item__title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item__badge {
  flex-shrink: 0;
  border-radius: 9999px;
  background: hsl(160 94% 30% / 0.1);
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--success);
}

.search-item__subtitle {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.0625rem;
}

/* Meta text (right side) */
.search-item__meta {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* Arrow icon (right) */
.search-item__arrow {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  color: var(--primary);
  opacity: 0;
  transform: translateX(-0.25rem);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.search-item:hover .search-item__arrow,
.search-item.is-active .search-item__arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ---- Separator between groups ---- */
.search-separator {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ---- Footer bar (tip / keyboard hints) ---- */
.search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  background: hsl(220 14% 96% / 0.4);
  padding: 0.625rem 1rem;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.search-footer__tip {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.search-footer__tip svg {
  width: 0.75rem;
  height: 0.75rem;
  color: var(--primary);
}

.search-footer__tip strong {
  color: var(--foreground);
  font-weight: 600;
}

.search-footer__keys {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-footer__keys span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

@media (max-width: 640px) {
  .search-footer__keys {
    display: none;
  }
}

.search-footer kbd {
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 0.125rem 0.25rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.625rem;
}

/* ---- Empty state (popular) header ---- */
.search-popular-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.5rem;
}

.search-popular-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-foreground);
}

.search-popular-label svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* ---- No results state ---- */
.search-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.search-empty__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

.search-empty__sub {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.search-empty__link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.search-empty__link:hover {
  text-decoration: underline;
}

.search-empty__link svg {
  width: 0.75rem;
  height: 0.75rem;
}

/* ---- Result count in footer ---- */
.search-footer__count strong {
  color: var(--foreground);
  font-weight: 600;
}

.search-footer__count {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
}

.search-footer__count:hover {
  color: var(--primary);
}

.search-footer__count svg {
  width: 0.625rem;
  height: 0.625rem;
}

/* ---- Loading state ---- */
.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.search-loading__spinner svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}

/* ---- Size variants (used via shortcode) ---- */
.search-wrapper--large .search-box__input {
  height: 4.5rem;
  font-size: 1rem;
}

.search-wrapper--hero {
  max-width: 720px;
}

.search-wrapper--hero .search-box__input {
  height: 5rem;
  font-size: 1.0625rem;
  margin-bottom:0px !important;
}

.search-wrapper--hero .search-box {
  border-radius: 1.25rem;
  box-shadow: 0 8px 30px -5px hsl(220 39% 11% / 0.12), 0 4px 16px -4px hsl(222 79% 48% / 0.10);
}

/* ============================================================
   FLATSOME OVERRIDES
   Flatsome sets global styles on input[type=text], button, etc.
   These rules undo those resets inside the search component.
   ============================================================ */
.search-wrapper .search-box__input,
.search-wrapper .search-box__input[type="text"] {
  height: 4rem;
  border: none !important;
  border-radius: 1rem !important;
  box-shadow: none !important;
  background-color: transparent !important;
  margin-bottom: 0 !important;
  padding: 0 8rem 0 3.5rem !important;
  font-size: 0.9375rem !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  line-height: normal !important;
  color: var(--foreground) !important;
}

.search-wrapper--large .search-box__input,
.search-wrapper--large .search-box__input[type="text"] {
  height: 4.5rem !important;
  font-size: 1rem !important;
}

.search-wrapper--hero .search-box__input,
.search-wrapper--hero .search-box__input[type="text"] {
  height: 5rem !important;
  font-size: 1.0625rem !important;
}

.search-wrapper .search-box__submit,
.search-wrapper .search-box__clear,
.search-wrapper button {
  margin-bottom: 0 !important;
  margin-right: 0 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  line-height: 1 !important;
  min-height: auto !important;
  min-width: auto !important;
  border-radius: var(--radius) !important;
}

.search-wrapper .search-box__submit.btjek-btn--green {
  background-color: hsl(160, 94%, 30%) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: none !important;
  padding: 14px 28px !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.search-wrapper .search-box__submit.btjek-btn--green:hover {
  background-color: hsl(160, 94%, 25%) !important;
  transform: translateY(-1px);
}

.search-wrapper .search-box__clear {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0.375rem !important;
}

/* ---- WP integration: remove standalone body reset ---- */
