/* ═══════════════════════════════════════════════════════════════
   Smart Select — Componente de Seleção com CRUD
   ═══════════════════════════════════════════════════════════════ */

.smart-select-container {
  position: relative;
  width: 100%;
}

/* ── Trigger/Button ─────────────────────────────────────────── */
.smart-select-input-wrapper {
  position: relative;
}

.smart-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5625rem 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.smart-select-trigger:hover {
  border-color: var(--primary);
  background: var(--surface);
}

.smart-select-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(43, 98, 214, 0.1);
}

.smart-select-valor {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-select-valor em {
  color: var(--text-3);
  font-style: normal;
}

.smart-select-trigger svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

/* ── Dropdown ───────────────────────────────────────────────── */
.smart-select-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 100%;
  max-height: 24rem;
}

/* ── Search Input ───────────────────────────────────────────── */
.smart-select-search {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.smart-select-search .form-control {
  margin: 0;
}

/* ── Lista de Registros ───────────────────────────────────────── */
.smart-select-list {
  flex: 1;
  overflow-y: auto;
  max-height: 16rem;
}

.smart-select-list::-webkit-scrollbar {
  width: 6px;
}

.smart-select-list::-webkit-scrollbar-track {
  background: transparent;
}

.smart-select-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.smart-select-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

.smart-select-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.smart-select-item:last-child {
  border-bottom: none;
}

.smart-select-item:hover {
  background: var(--surface);
}

.smart-select-item-content {
  flex: 1;
  padding: 0.75rem;
  cursor: pointer;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.smart-select-item-nome {
  color: var(--text);
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-select-item-actions {
  display: flex;
  gap: 0.25rem;
  padding-right: 0.5rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.smart-select-item:hover .smart-select-item-actions {
  opacity: 1;
}

.smart-select-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.smart-select-btn-icon:hover {
  background: var(--border);
  color: var(--text);
}

.smart-select-btn-icon.smart-select-btn-delete:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.smart-select-btn-icon svg {
  width: 1rem;
  height: 1rem;
}

/* ── Empty State ────────────────────────────────────────────── */
.smart-select-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
}

/* ── Actions ────────────────────────────────────────────────── */
.smart-select-actions {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.smart-select-btn-novo {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.smart-select-btn-novo:hover {
  border-color: var(--primary);
  background: rgba(43, 98, 214, 0.05);
}

.smart-select-btn-novo svg {
  width: 1rem;
  height: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   Theme Variants (Light/Dark)
   ═══════════════════════════════════════════════════════════════ */

html.dark .smart-select-dropdown {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html.dark .smart-select-item:hover {
  background: var(--surface);
}

html.dark .smart-select-search {
  border-bottom-color: var(--border);
}

html.dark .smart-select-item {
  border-bottom-color: var(--border);
}

html.dark .smart-select-actions {
  background: var(--surface);
  border-top-color: var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .smart-select-dropdown {
    max-height: calc(100vh - 10rem);
  }

  .smart-select-list {
    max-height: calc(100vh - 14rem);
  }

  .smart-select-item-actions {
    opacity: 1;
  }
}
