/* Search page — homepage + results */

.hero-title--search {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary-text);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

/* Search bar */
.search-bar {
  margin: 1.5rem auto 1rem;
  max-width: 750px;
}

.search-input-wrapper {
  background: linear-gradient(to bottom, #e8e8e8 0%, #f2f2f2 40%, #ffffff 100%);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 32px;
  padding: 20px 28px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    inset 0 1px 2px rgba(255, 255, 255, 0.8),
    inset 0 -1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-input-wrapper button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  color: #888;
  order: 1;
}

.search-input-wrapper button:hover {
  color: #000;
}

.search-input-wrapper button svg {
  width: 32px;
  height: 32px;
  stroke: currentColor;
}

/* Input container */
.search-input-container {
  flex: 1;
  min-width: 0;
  order: 0;
}

/* Contenteditable search input */
#search-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--primary-text);
  outline: none;
  font-family: inherit;
  text-align: center;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-user-modify: read-write-plaintext-only;
}

#search-input::-webkit-scrollbar {
  display: none;
}

#search-input:empty:before {
  content: attr(data-placeholder);
  color: var(--primary-text);
  pointer-events: none;
}

/* Inline highlight marks */
#search-input mark {
  color: inherit;
  border-radius: 3px;
  padding: 2px 1px;
}

#search-input .hl-estado { background: #dbeafe; }
#search-input .hl-tipo { background: #dcfce7; }
#search-input .hl-cargas { background: #fef3c7; }
#search-input .hl-localidad { background: #f3e8ff; }

/* Selectors row */
.search-selectors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  justify-content: center;
  align-items: flex-start;
}

/* ── Multi-select dropdown component ────────────────────── */
.multi-select {
  position: relative;
}

.multi-select-btn {
  background-color: #fff;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.75rem;
  padding: 0.5rem 2.25rem 0.5rem 1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--primary-text);
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  transition: background-color 0.15s, border-color 0.2s;
}

.multi-select[data-group="estado"] .multi-select-btn:hover { border-color: #93c5fd; }
.multi-select[data-group="tipo"] .multi-select-btn:hover { border-color: #86efac; }
.multi-select[data-group="cargas"] .multi-select-btn:hover { border-color: #fcd34d; }
.multi-select[data-group="localidad"] .multi-select-btn:hover { border-color: #c4b5fd; }

/* Color-coded active states */
.multi-select[data-group="estado"].has-selection .multi-select-btn {
  background-color: #dbeafe;
  border-color: #93c5fd;
}

.multi-select[data-group="tipo"].has-selection .multi-select-btn {
  background-color: #dcfce7;
  border-color: #86efac;
}

.multi-select[data-group="cargas"].has-selection .multi-select-btn {
  background-color: #fef3c7;
  border-color: #fcd34d;
}

.multi-select[data-group="localidad"].has-selection .multi-select-btn {
  background-color: #f3e8ff;
  border-color: #c4b5fd;
}

/* Dropdown panel */
.multi-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 20;
  max-height: 250px;
  overflow-y: auto;
  padding: 0.375rem 0;
}

.multi-select.open .multi-select-dropdown {
  display: block;
}

.multi-select-dropdown label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  white-space: nowrap;
  color: var(--primary-text);
  transition: background-color 0.1s;
}

.multi-select-dropdown label:hover {
  background-color: #f3f4f6;
}

.multi-select-dropdown input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: #4b5563;
  cursor: pointer;
  flex-shrink: 0;
}

/* Results hero (compact search bar on /buscar) */
.results-hero {
  padding: 1rem 0 0;
}

/* Results section */
.results-section {
  margin-top: 1.5rem;
  min-height: 200px;
}

.results-count {
  font-size: 0.875rem;
  color: var(--primary-text);
  font-weight: 500;
  margin-bottom: 1rem;
}

/* Card description label */
.card-label {
  font-weight: 600;
  color: var(--primary-text);
}

/* Search loading / sentinel */
.search-loading {
  text-align: center;
  padding: 2rem 0;
  color: #6b7280;
}

.scroll-sentinel {
  height: 1px;
}

.search-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: var(--primary-text);
}

.search-empty p {
  margin: 0.5rem 0;
}

/* Skeleton loading cards */
.skeleton-card {
  pointer-events: none;
}

.skeleton-line {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.skeleton-title {
  height: 1.25rem;
  width: 70%;
}

.skeleton-meta {
  height: 1rem;
  width: 40%;
}

.skeleton-desc {
  height: 0.875rem;
  width: 90%;
}

.skeleton-desc-short {
  height: 0.875rem;
  width: 55%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Cards grid */
.search-results.subastas-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Status badges */
.search-results .status-badge {
  display: inline-block;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.search-results .status-celebrandose { background: #d1fae5; color: #065f46; }
.search-results .status-prox_apertura { background: #dbeafe; color: #1e40af; }
.search-results .status-suspendida { background: #fed7aa; color: #92400e; }
.search-results .status-finalizada { background: #e5e7eb; color: #374151; }
.search-results .status-concluida { background: #e9d5ff; color: #6b21a8; }
.search-results .status-cancelada { background: #fee2e2; color: #991b1b; }

/* Search result card */
.search-card {
  transition: border-color 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
}

.search-card.box {
  padding: 1.25rem 1.5rem;
}

.search-card .bookmark-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
}

.card-chat-link {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem auto 0;
  background: #111827;
  color: #fff;
  border: none;
  border-radius: 20px;
  height: 40px;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.card-chat-link:hover {
  background: #1f2937;
}

.search-card:hover {
  border-color: #000;
}

.search-card h3 {
  margin: 0 0 0.5rem;
  padding-right: 2rem;
  word-break: break-word;
  font-size: 1.4rem;
}

.search-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.search-card-meta .meta-sep {
  color: #d1d5db;
}

.search-card p {
  margin: 0.35rem 0;
  color: #6b7280;
}

.search-card .countdown {
  font-weight: 600;
}

/* Two-column data grid within card */
.search-card-data {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}

.search-card-data p {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Description spans full width — first row */
.search-card-data .search-card-desc {
  grid-column: 1 / -1;
}

/* Left-column data cells (even children: 2nd=ID, 4th=Autoridad) get right border */
.search-card-data p:nth-child(even) {
  border-right: 1px solid #e5e7eb;
}

/* Last row — no bottom border */
.search-card-data p:nth-last-child(-n+2) {
  border-bottom: none;
}

.boe-card-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* Risk levels */
.search-card .risk-alto { color: #dc2626; font-weight: 600; }
.search-card .risk-medio-alto,
.search-card .risk-med-alto { color: #ea580c; font-weight: 600; }
.search-card .risk-medio { color: #ca8a04; font-weight: 600; }
.search-card .risk-medio-bajo,
.search-card .risk-med-bajo { color: #16a34a; font-weight: 600; }
.search-card .risk-bajo { color: #059669; font-weight: 600; }

/* Mobile */
@media (max-width: 767px) {
  .hero-title--search {
    font-size: 1.75rem;
  }

  .search-input-wrapper {
    padding: 14px 20px;
    gap: 12px;
  }

  .search-input-wrapper button svg {
    width: 24px;
    height: 24px;
  }

  #search-input {
    font-size: 16px;
  }

  .multi-select-btn {
    font-size: 0.8125rem;
    padding: 0.4375rem 2rem 0.4375rem 0.875rem;
  }

  .search-results.subastas-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .search-card-data {
    grid-template-columns: 1fr;
  }

  .search-card-data p:nth-child(even) {
    border-right: none;
  }

  .search-card-data p:nth-last-child(-n+2) {
    border-bottom: 1px solid #e5e7eb;
  }

  .search-card-data p:last-child {
    border-bottom: none;
  }
}

/* Compact h1 when results are shown */
.hero-title--compact {
  font-size: 0.875rem;
}

/* Desktop */
@media (min-width: 768px) {
  .hero-title--search {
    font-size: 1.7rem;
  }
  .hero-title--compact {
    font-size: 1.5rem;
  }
}

/* Homepage title override */
.page-home .hero-title--search {
  font-size: 2.2rem;
  line-height: 2rem;
  margin-bottom: 30px;
}
