/* ── Search wrapper ─────────────────────────────────────────────────────── */

#search-wrapper {
  position: fixed;
  bottom: 20px;
  left: 70px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50px;
  padding: 6px;
  box-shadow: var(--shadow-card);
  transition: width 0.3s cubic-bezier(0.4,0,0.2,1),
              border-color 0.2s,
              padding 0.3s cubic-bezier(0.4,0,0.2,1);
  width: 44px;
  overflow: hidden;
  pointer-events: all;
}

#search-bar.search-expanded {
  width: 100%;
  max-width: 420px;
  border-color: var(--accent);
}

/* ── Icon button ────────────────────────────────────────────────────────── */
#search-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: var(--text-secondary);
  transition: color 0.2s;
}

#search-bar.search-expanded #search-icon-btn {
  color: #ff4444;
}

#search-svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* ── Input ──────────────────────────────────────────────────────────────── */
#search-input-wrapper {
  flex: 1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease 0.1s;
}

#search-bar.search-expanded #search-input-wrapper {
  opacity: 1;
}

#search-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  padding: 0 10px 0 8px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  caret-color: var(--accent);
}

#search-input::placeholder {
  color: var(--text-secondary);
  font-size: 0.78rem;
}

/* ── Results panel ──────────────────────────────────────────────────────── */
#search-results {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-float);
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 8px;
  gap: 6px;
  flex-direction: column;
  pointer-events: all;
}

#search-results::-webkit-scrollbar { width: 4px; }
#search-results::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#search-results.visible {
  display: flex;
}

/* ── Result cards ───────────────────────────────────────────────────────── */
.sr-card {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.sr-card-header {
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: start;
}

.sr-icon {
  grid-row: 1 / 3;
  font-size: 1rem;
  padding-top: 1px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.sr-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sr-card-sub {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sr-team-bar {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Highlighted match text ─────────────────────────────────────────────── */
.sr-highlight {
  color: var(--accent);
  font-weight: 800;
}

/* ── Action buttons ─────────────────────────────────────────────────────── */
.sr-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sr-btn {
  background: var(--bg-pill);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sr-btn:hover {
  background: var(--bg-pill-hover);
}

.sr-btn.sr-btn-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.sr-empty {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 16px 8px;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #search-wrapper {
    bottom: 16px;
    left: 60px;
    right: 12px;
  }

  #search-bar {
    width: 38px;
  }

  #search-bar.search-expanded {
    max-width: 100%;
  }

  #search-input {
    font-size: 0.74rem;
  }

  #search-results {
    max-height: 50vh;
    border-radius: 14px;
  }
}

body.circuit-panel-open #search-wrapper {
  display: none;
}