/* ═══════════════════════════════════════════════════════════════
   Unified Search  —  Command Palette Styles
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --us-bg: #1a1b2e;
  --us-bg-light: #232540;
  --us-border: rgba(255, 255, 255, 0.08);
  --us-text: #e2e8f0;
  --us-text-muted: #94a3b8;
  --us-accent: #6366f1;
  --us-highlight-bg: rgba(99, 102, 241, 0.15);
  --us-overlay-bg: rgba(0, 0, 0, 0.6);
  --us-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  --us-radius: 16px;
  --us-radius-sm: 8px;
}

/* ── Body scroll lock ──────────────────────────────────────── */
.us-body-lock {
  overflow: hidden !important;
}

/* ── Overlay ───────────────────────────────────────────────── */
.us-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: var(--us-overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.us-overlay.us-visible {
  opacity: 1;
  visibility: visible;
}

/* ── Palette Container ─────────────────────────────────────── */
.us-palette {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  z-index: 99999;
  width: 680px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: var(--us-bg);
  border: 1px solid var(--us-border);
  border-radius: var(--us-radius);
  box-shadow: var(--us-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}
.us-palette.us-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* ── Header ────────────────────────────────────────────────── */
.us-header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--us-border);
}

.us-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.us-input-icon {
  color: var(--us-text-muted);
  font-size: 16px;
  flex-shrink: 0;
}

.us-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--us-text);
  font-size: 16px;
  font-family: inherit;
  padding: 8px 0;
  caret-color: var(--us-accent);
}
.us-input::placeholder {
  color: var(--us-text-muted);
  font-size: 14px;
}

.us-kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--us-border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--us-text-muted);
  font-family: inherit;
  flex-shrink: 0;
}

/* ── Module Badge ──────────────────────────────────────────── */
.us-module-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.us-badge-x {
  cursor: pointer;
  margin-left: 2px;
  font-size: 14px;
  opacity: 0.7;
}
.us-badge-x:hover {
  opacity: 1;
}

/* ── Filters Bar ───────────────────────────────────────────── */
.us-filters {
  display: flex;
  gap: 6px;
  padding: 8px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.us-filters::-webkit-scrollbar {
  display: none;
}

/* ── Body / Results ────────────────────────────────────────── */
.us-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.us-body::-webkit-scrollbar {
  width: 6px;
}
.us-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}

/* ── Group ─────────────────────────────────────────────────── */
.us-group {
  margin-bottom: 8px;
}

.us-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--us-text-muted);
}
.us-group-count {
  margin-left: auto;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.6;
}

/* ── Result Item ───────────────────────────────────────────── */
.us-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--us-radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}
.us-result-item:hover,
.us-result-item.us-active {
  background: var(--us-highlight-bg);
}

.us-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
  flex-shrink: 0;
}

.us-item-body {
  flex: 1;
  min-width: 0;
}

.us-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--us-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.us-item-sub {
  font-size: 12px;
  color: var(--us-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.us-item-count {
  font-size: 11px;
  color: var(--us-text-muted);
  flex-shrink: 0;
}

/* ── Module Pill ───────────────────────────────────────────── */
.us-mod-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Type Badge ────────────────────────────────────────────── */
.us-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--us-text-muted);
  margin-left: 6px;
  text-transform: capitalize;
}

/* ── Highlight Match ───────────────────────────────────────── */
mark.us-highlight {
  background: rgba(99, 102, 241, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Empty State ───────────────────────────────────────────── */
.us-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--us-text-muted);
}
.us-empty i {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.us-empty p {
  margin: 4px 0;
  font-size: 14px;
}
.us-empty-hint {
  font-size: 12px !important;
  opacity: 0.6;
}
.us-error i {
  color: #ef4444;
  opacity: 0.8;
}

/* ── "More" indicator ──────────────────────────────────────── */
.us-more {
  text-align: center;
  font-size: 12px;
  color: var(--us-text-muted);
  padding: 8px;
  opacity: 0.6;
}

/* ── Loading spinner ───────────────────────────────────────── */
.us-loading {
  text-align: center;
  padding: 30px;
  color: var(--us-text-muted);
  font-size: 20px;
}

/* ── Footer ────────────────────────────────────────────────── */
.us-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--us-border);
  font-size: 11px;
  color: var(--us-text-muted);
}
.us-footer kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--us-border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
}

/* ── Search Trigger Button ─────────────────────────────────── */
.us-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  padding: 9px 20px;
  background: rgba(255, 255, 255, 0.10);
  border: 2px solid rgba(255, 255, 255, 0.40);
  border-radius: 10px;
  color: var(--us-text-muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.us-trigger:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--us-text);
  border-color: var(--us-accent);
  box-shadow: 0 0 0 2px var(--us-accent);
}

.us-trigger-text {
  opacity: 0.7;
}

.us-trigger-kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--us-text-muted);
}

/* Fixed position fallback trigger */
.us-trigger-fixed {
  position: fixed;
  top: 12px;
  right: 20px;
  z-index: 9990;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .us-palette {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .us-palette.us-visible {
    transform: none;
  }
  .us-trigger-text {
    display: none;
  }
  .us-trigger-kbd {
    display: none;
  }
  .us-trigger {
    padding: 6px 10px;
  }
  .us-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
  .us-footer span:nth-child(n+3) {
    display: none;
  }
}

@media (max-width: 480px) {
  .us-input {
    font-size: 14px;
  }
  .us-result-item {
    padding: 8px 10px;
    gap: 10px;
  }
  .us-mod-pill {
    display: none;
  }
}
