/* ==========================================================================
   LE41 PRO - GLOBAL SEARCH ENGINE & OMNIBOX STYLESHEET
   Glassmorphism command palette, quick search bar, category pills,
   live result highlights, smooth animations & dark/light mode support.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOPBAR SEARCH TRIGGER COMPONENT
   -------------------------------------------------------------------------- */

.topbar-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 220px;
  margin: 0 1rem;
}

.topbar-search-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  padding: 0 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.86rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.topbar-search-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  color: var(--text-main);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
  transform: translateY(-1px);
}

.topbar-search-btn:focus-visible {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-btn-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-btn-left i {
  width: 17px;
  height: 17px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.search-btn-placeholder {
  font-weight: 500;
  color: var(--text-muted);
}

.search-kbd-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-subtle);
  letter-spacing: 0.5px;
}

/* Mobile search icon button */
.mobile-search-btn {
  display: none;
}

/* --------------------------------------------------------------------------
   2. OMNIBOX / COMMAND PALETTE MODAL BACKDROP & CARD
   -------------------------------------------------------------------------- */

.search-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem 1rem 1rem;
  background: rgba(11, 17, 32, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease, visibility 200ms ease;
}

[data-theme="light"] .search-palette-backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.search-palette-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.search-palette-card {
  position: relative;
  width: 100%;
  max-width: 760px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-modal);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.15);
  overflow: hidden;
  animation: searchPaletteZoom 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .search-palette-card {
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@keyframes searchPaletteZoom {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Glowing top ambient gradient line */
.search-palette-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #3b82f6);
  z-index: 2;
}

/* --------------------------------------------------------------------------
   3. SEARCH INPUT BAR (TOP OF PALETTE)
   -------------------------------------------------------------------------- */

.search-input-header {
  position: relative;
  display: flex;
  align-items: center;
  padding: 1.15rem 1.25rem 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-modal);
}

.search-input-icon {
  width: 22px;
  height: 22px;
  color: var(--color-primary);
  flex-shrink: 0;
  margin-right: 0.85rem;
}

.search-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.search-palette-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 1.05rem;
}

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

.search-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-close-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.search-close-btn i {
  width: 18px;
  height: 18px;
}

/* --------------------------------------------------------------------------
   4. CATEGORY PILLS & QUICK FILTERS
   -------------------------------------------------------------------------- */

.search-pills-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.search-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.search-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--color-primary);
}

.search-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.pill-icon {
  width: 13px;
  height: 13px;
}

/* --------------------------------------------------------------------------
   5. SEARCH HISTORY & RECENT SEARCHES
   -------------------------------------------------------------------------- */

.search-history-box {
  padding: 0.75rem 1.25rem;
  background: rgba(99, 102, 241, 0.04);
  border-bottom: 1px solid var(--border-subtle);
}

.search-history-box.hidden {
  display: none;
}

.search-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-history-header span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.search-history-header span i {
  width: 14px;
  height: 14px;
}

.btn-clear-history {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.btn-clear-history:hover {
  color: var(--color-danger);
}

.search-history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.search-history-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-history-tag:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

.search-history-tag i {
  width: 12px;
  height: 12px;
  color: var(--text-subtle);
}

/* --------------------------------------------------------------------------
   6. SEARCH RESULTS LIST & ITEMS
   -------------------------------------------------------------------------- */

.search-results-list {
  flex: 1;
  overflow-y: auto;
  max-height: 52vh;
  padding: 0.65rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  scrollbar-width: thin;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.95rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateX(3px);
}

[data-theme="light"] .search-result-item:hover,
[data-theme="light"] .search-result-item.selected {
  background: #f1f5f9;
  border-color: rgba(99, 102, 241, 0.4);
}

.search-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.search-result-item:hover .search-item-icon,
.search-result-item.selected .search-item-icon {
  transform: scale(1.08);
}

.search-item-icon i {
  width: 20px;
  height: 20px;
}

.search-item-body {
  flex: 1;
  min-width: 0;
}

.search-item-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.2rem;
}

.search-item-title {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-category-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.search-item-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-item-action {
  opacity: 0;
  color: var(--color-primary);
  transition: all var(--transition-fast);
  transform: translateX(-4px);
}

.search-result-item:hover .search-item-action,
.search-result-item.selected .search-item-action {
  opacity: 1;
  transform: translateX(0);
}

.search-item-action i {
  width: 18px;
  height: 18px;
}

/* Term highlight styling */
.search-highlight {
  background: rgba(99, 102, 241, 0.35);
  color: #ffffff;
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 800;
}

[data-theme="light"] .search-highlight {
  background: rgba(99, 102, 241, 0.25);
  color: #312e81;
}

/* --------------------------------------------------------------------------
   7. EMPTY STATE
   -------------------------------------------------------------------------- */

.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.search-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  margin-bottom: 1rem;
}

.search-empty-icon i {
  width: 28px;
  height: 28px;
}

.search-empty-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.search-empty-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 440px;
}

/* --------------------------------------------------------------------------
   8. FOOTER BAR WITH SHORTCUTS & RESULT COUNT
   -------------------------------------------------------------------------- */

.search-palette-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.search-footer-shortcuts {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.shortcut-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.shortcut-kbd {
  padding: 1px 5px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
}

.search-results-count-badge {
  font-weight: 600;
  color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   9. RESPONSIVE MEDIA QUERIES (TABLETS & SMARTPHONES)
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .topbar-search-wrapper {
    max-width: 300px;
    margin: 0 0.5rem;
  }
}

@media (max-width: 900px) {
  .topbar-search-wrapper {
    max-width: 220px;
    margin: 0 0.4rem;
  }
  .search-btn-placeholder {
    font-size: 0.8rem;
  }
  .search-kbd-shortcut {
    display: none;
  }
}

@media (max-width: 768px) {
  .topbar-search-wrapper {
    display: none;
  }
  
  .mobile-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    cursor: pointer;
    transition: all var(--transition-fast);
  }

  .mobile-search-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
  }

  .mobile-search-btn i {
    width: 18px;
    height: 18px;
  }

  .search-palette-backdrop {
    padding: 1.5vh 0.5rem 0.5rem 0.5rem;
  }

  .search-palette-card {
    max-height: 94vh;
    border-radius: var(--radius-md);
  }

  .search-input-header {
    padding: 0.85rem 1rem 0.65rem 1rem;
  }

  .search-palette-input {
    font-size: 1rem;
  }

  .search-pills-bar {
    padding: 0.5rem 0.85rem;
  }

  .search-results-list {
    padding: 0.5rem;
    max-height: 60vh;
  }

  .search-result-item {
    padding: 0.65rem 0.75rem;
    gap: 0.65rem;
  }

  .search-palette-footer .search-footer-shortcuts {
    display: none;
  }
}

