/* ==========================================================
   Global Search — dropdown del buscador del header
   ==========================================================
   Estructura DOM:
     .topbar-search                   (contenedor existente)
       .input-wrap
         input[data-role="global-search"]
       .gsearch-dropdown
         .gsearch-hint      (placeholder inicial / "sin resultados")
         .gsearch-block     (uno por provider: clientes, productos, ...)
           .gsearch-block-head
             <i class="fa">  <span>Label</span>
           .gsearch-item      (.active para highlight del teclado)
             .gsearch-icon
             .gsearch-text
               .gsearch-title
               .gsearch-sub
         .gsearch-footer    (tips: ↑↓ navegar · Enter abrir · Esc cerrar)
   ========================================================== */

.topbar-search { position: relative; }

.gsearch-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-1, #fff);
  color: var(--fg-1, #222);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  z-index: 1100;
  display: none;
  padding: 6px 0 4px;
  font-size: 13px;
}

.gsearch-dropdown.open { display: block; }

.gsearch-hint {
  padding: 14px 14px 12px;
  color: var(--fg-3, #888);
  font-size: 13px;
  text-align: center;
}
.gsearch-hint.loading { color: var(--fg-2, #666); }
.gsearch-hint.error   { color: #c0392b; }

.gsearch-block + .gsearch-block {
  border-top: 1px solid var(--border, rgba(0,0,0,0.06));
  margin-top: 4px;
  padding-top: 4px;
}

.gsearch-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--fg-3, #888);
}
.gsearch-block-head i { font-size: 11px; }

.gsearch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .1s ease;
  user-select: none;
}
.gsearch-item:hover,
.gsearch-item.active {
  background: rgba(25, 118, 210, 0.08);
}
.gsearch-item.active {
  box-shadow: inset 3px 0 0 #1976d2;
}

.gsearch-icon {
  width: 28px; height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(25, 118, 210, 0.12);
  color: #1976d2;
  border-radius: 6px;
  font-size: 13px;
}
.gsearch-item[data-type="product"]  .gsearch-icon { background: rgba(46, 125, 50, 0.12);  color: #2e7d32; }
.gsearch-item[data-type="supplier"] .gsearch-icon { background: rgba(230, 81, 0, 0.12);   color: #e65100; }
.gsearch-item[data-type="invoice"]  .gsearch-icon { background: rgba(123, 31, 162, 0.12); color: #7b1fa2; }
.gsearch-item[data-type="command"]  .gsearch-icon { background: rgba(69, 90, 100, 0.14);  color: #455a64; }

.gsearch-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gsearch-title {
  font-weight: 600;
  color: var(--fg-1, #222);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gsearch-sub {
  color: var(--fg-3, #888);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gsearch-item mark {
  background: rgba(255, 235, 59, 0.45);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

.gsearch-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  border-top: 1px solid var(--border, rgba(0,0,0,0.06));
  margin-top: 4px;
  color: var(--fg-3, #888);
  font-size: 11px;
}
.gsearch-footer kbd {
  display: inline-block;
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: inherit;
  margin: 0 2px;
}

/* Dark mode */
[data-theme="dark"] .gsearch-dropdown,
.theme-dark          .gsearch-dropdown {
  background: #23272e;
  color: #e6e9ef;
  border-color: #3a404b;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .gsearch-item:hover,
[data-theme="dark"] .gsearch-item.active,
.theme-dark          .gsearch-item:hover,
.theme-dark          .gsearch-item.active {
  background: rgba(108, 182, 255, 0.12);
}
[data-theme="dark"] .gsearch-block + .gsearch-block,
[data-theme="dark"] .gsearch-footer,
.theme-dark          .gsearch-block + .gsearch-block,
.theme-dark          .gsearch-footer {
  border-color: #3a404b;
}
[data-theme="dark"] .gsearch-footer kbd,
.theme-dark          .gsearch-footer kbd {
  background: #2c313a;
  border-color: #3a404b;
}

/* Responsive — en pantallas chicas el dropdown ocupa toda la topbar */
@media (max-width: 600px) {
  .gsearch-dropdown {
    left: -8px;
    right: -8px;
  }
}
