/* ==========================================================================
   Solsano · search.css
   Command palette (desktop) + full-screen sheet (móvil)
   ========================================================================== */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  background: rgba(18, 49, 41, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.search-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-dialog {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 200ms ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.search-overlay.is-open .search-dialog {
  transform: none;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top, 14px));
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  background: #EFE7DA;
  border-radius: 8px;
  padding: 0 14px;
  min-height: 48px;
}

.search-input-wrap:focus-within {
  outline: 2px solid #015351;
  outline-offset: 1px;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 16px; /* evita zoom iOS */
  line-height: 1.4;
  color: #123129;
  outline: none;
  /* evita la X nativa del navegador (type=search / WebKit / Edge) */
  -webkit-appearance: none;
  appearance: none;
}

.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.search-input::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}

.search-input::placeholder {
  color: rgba(18, 49, 41, 0.5);
}

/* Borrar texto: compacto, dentro del campo */
.search-clear {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-right: -4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #123129;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-clear:hover {
  background: rgba(0, 0, 0, 0.06);
}

.search-clear[hidden] {
  display: none !important;
}

/* Cerrar overlay: solo móvil, fuera del campo */
.search-close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #123129;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.search-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.search-kbd {
  display: none;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.search-kbd kbd {
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  line-height: 1;
  color: rgba(18, 49, 41, 0.65);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  padding: 5px 7px;
}

.search-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 24px;
}

.search-section-label {
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(58, 58, 58, 0.65);
  padding: 10px 12px 6px;
}

.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  transition: background-color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

.search-item:hover,
.search-item.is-active,
.search-item:focus-visible {
  background: #EFE7DA;
  outline: none;
}

.search-item-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #D6F9DC;
  color: #015351;
  display: grid;
  place-items: center;
}

.search-item-icon [data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
}

.search-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-item-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  color: #123129;
}

.search-item-title mark {
  background: #67ED6E;
  color: #123129;
  border-radius: 2px;
  padding: 0 1px;
}

.search-item-meta {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(58, 58, 58, 0.75);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-item-meta mark {
  background: rgba(103, 237, 110, 0.45);
  color: inherit;
  border-radius: 2px;
}

.search-item-badge {
  flex-shrink: 0;
  align-self: center;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: #015351;
  background: #D6F9DC;
  border-radius: 4px;
  padding: 6px 8px;
  white-space: nowrap;
}

.search-empty {
  padding: 28px 16px;
  text-align: center;
}

.search-empty p {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
  color: #123129;
}

.search-empty span {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(58, 58, 58, 0.75);
  margin-bottom: 18px;
}

.search-empty a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #67ED6E;
  color: #123129;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.search-footer {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 12px;
  color: rgba(58, 58, 58, 0.65);
}

.search-footer-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.search-footer-hints span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.search-footer kbd {
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  line-height: 1;
  color: rgba(18, 49, 41, 0.7);
  background: #EFE7DA;
  border-radius: 4px;
  padding: 4px 6px;
}

body.search-open {
  overflow: hidden;
}

/* Desktop / tablet landscape: command palette centrado */
@media (min-width: 640px) {
  .search-overlay {
    align-items: flex-start;
    padding: 10vh 24px 24px;
  }

  .search-dialog {
    width: min(640px, 100%);
    height: auto;
    max-height: min(72vh, 680px);
    border-radius: 12px;
    box-shadow: 0 24px 64px -16px rgba(18, 49, 41, 0.35);
    transform: translateY(8px) scale(0.98);
  }

  .search-overlay.is-open .search-dialog {
    transform: none;
  }

  .search-header {
    padding: 12px 14px;
  }

  .search-input-wrap {
    min-height: 44px;
  }

  .search-kbd {
    display: inline-flex;
  }

  .search-close {
    display: none;
  }

  .search-footer {
    display: flex;
  }

  .search-body {
    padding: 8px 10px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-overlay,
  .search-dialog {
    transition: none !important;
  }
}
