/* ═══════════════════════════════════════════════════════════════
   Champion Motors — Premium Search Box
   Glassmorphism + Modern UI
   ═══════════════════════════════════════════════════════════════ */

/* Search trigger button in navbar */
.cm-search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.3s ease;
  color: #fff;
  font-size: 15px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.cm-search-trigger:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.5);
  transform: scale(1.08);
}

/* ── Full-screen overlay ──────────────────────────────────── */
.cm-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  padding-bottom: 4vh;
  background: rgba(10, 12, 20, 0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.cm-search-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Close button */
.cm-search-close {
  position: absolute;
  top: 24px;
  right: 32px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.cm-search-close:hover {
  background: rgba(255,80,80,0.3);
  border-color: rgba(255,80,80,0.5);
  transform: rotate(90deg);
}

/* ── Search container ─────────────────────────────────────── */
.cm-search-container {
  width: 90%;
  max-width: 640px;
  transform: translateY(-20px);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.cm-search-overlay.active .cm-search-container {
  transform: translateY(0);
}

/* ── Input wrapper ────────────────────────────────────────── */
.cm-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px;
  padding: 0 20px;
  transition: all 0.3s ease;
}
.cm-search-input-wrap:focus-within {
  background: rgba(255,255,255,0.12);
  border-color: rgba(28, 52, 144, 0.7);
  box-shadow: 0 0 0 3px rgba(28, 52, 144, 0.2), 0 8px 32px rgba(0,0,0,0.3);
}

.cm-search-input-wrap .cm-icon {
  color: rgba(255,255,255,0.5);
  font-size: 18px;
  margin-right: 14px;
  flex-shrink: 0;
}

.cm-search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 18px;
  font-weight: 300;
  padding: 18px 0;
  letter-spacing: 0.3px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.cm-search-input-wrap input::placeholder {
  color: rgba(255,255,255,0.35);
  font-weight: 300;
}

/* Spinner */
.cm-search-spin {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #4e7cff;
  border-radius: 50%;
  animation: cm-spin 0.6s linear infinite;
  flex-shrink: 0;
  margin-left: 10px;
}
@keyframes cm-spin {
  to { transform: rotate(360deg); }
}

/* ── Results dropdown ─────────────────────────────────────── */
.cm-search-results {
  margin-top: 8px;
  background: rgba(20, 24, 36, 0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.cm-search-results.show {
  max-height: 520px;
  opacity: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Scrollbar */
.cm-search-results::-webkit-scrollbar { width: 6px; }
.cm-search-results::-webkit-scrollbar-track { background: transparent; }
.cm-search-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

/* ── Result item ──────────────────────────────────────────── */
.cm-search-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  text-decoration: none;
  color: #fff;
  transition: background 0.2s ease;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cm-search-item:last-of-type {
  border-bottom: none;
}
.cm-search-item:hover {
  background: rgba(28, 52, 144, 0.25);
}

.cm-search-thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}

.cm-search-info {
  flex: 1;
  min-width: 0;
}
.cm-search-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.cm-search-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.cm-search-price {
  font-size: 15px;
  font-weight: 600;
  color: #f5c518;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── "Ver todos" link ─────────────────────────────────────── */
.cm-search-all {
  display: block;
  text-align: center;
  padding: 14px;
  color: #4e9aff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  transition: background 0.2s ease;
}
.cm-search-all:hover {
  background: rgba(78, 154, 255, 0.1);
}

/* ── Empty state ──────────────────────────────────────────── */
.cm-search-empty {
  padding: 32px 20px;
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
}
.cm-search-empty::before {
  content: '🔍';
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
}

/* ── Keyboard hint ────────────────────────────────────────── */
.cm-search-hint {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: rgba(255,255,255,0.25);
}
.cm-search-hint kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  background: rgba(255,255,255,0.06);
  margin: 0 2px;
}

/* ── Mobile adjustments ───────────────────────────────────── */
@media (max-width: 768px) {
  .cm-search-overlay { padding-top: 3vh; padding-bottom: 2vh; }
  .cm-search-container { width: 94%; max-height: 90vh; }
  .cm-search-input-wrap input { font-size: 16px; padding: 14px 0; }
  .cm-search-results.show { max-height: 55vh; }
  .cm-search-thumb { width: 60px; height: 40px; }
  .cm-search-close { top: 12px; right: 12px; width: 36px; height: 36px; font-size: 18px; }
  .cm-search-trigger { width: 34px; height: 34px; font-size: 14px; }
  .cm-search-hint { display: none; }
}

/* ── Catalog page dropdown overrides ──────────────────────── */
.cm-cat-dropdown {
  background: rgba(15, 18, 28, 0.98) !important;
  border-radius: 12px !important;
  max-height: 0 !important;
  transition: max-height 0.3s ease, opacity 0.25s ease !important;
}
.cm-cat-dropdown.show {
  max-height: 400px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 768px) {
  .cm-cat-dropdown.show { max-height: 50vh !important; }
}

/* ── Homepage results fix (inline styles override) ───────── */
.cm-search .cm-search-results {
  max-height: 280px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain;
}
@media (max-width: 768px) {
  .cm-search .cm-search-results {
    max-height: 35vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* ── Hide ghost trigger on pages with existing search ────── */
.cm-search-trigger {
  order: 99;
  margin-left: 8px;
}

/* ── Block jQuery UI autocomplete widget ─────────────────── */
.ui-autocomplete, .ui-menu, .ui-widget.ui-autocomplete {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
}
