/* Custom Dropdown - Diseño Profesional y Moderno */

/* Contenedor principal del dropdown personalizado */
.custom-project-selector {
  position: relative;
  min-width: 275px;  /* 220px * 1.25 = 275px */
  max-width: 450px;  /* 360px * 1.25 = 450px */
  user-select: none;
}

/* Botón principal del selector (trigger) */
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 var(--spacing-4);
  padding-right: var(--spacing-3);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background:
    linear-gradient(var(--color-bg-primary), var(--color-bg-primary)) padding-box,
    linear-gradient(to right, #667eea, #764ba2) border-box;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow:
    var(--shadow-xs),
    inset 0 0 0 1px var(--color-border);
  position: relative;
}

.custom-select-trigger:hover {
  background:
    linear-gradient(var(--color-bg-secondary), var(--color-bg-tertiary)) padding-box,
    linear-gradient(to right, #5568d3, #653a8a) border-box;
  box-shadow:
    var(--shadow-sm),
    inset 0 0 0 1px transparent;
  transform: translateY(-1px);
}

.custom-select-trigger.active {
  background:
    linear-gradient(var(--color-bg-primary), var(--color-bg-secondary)) padding-box,
    linear-gradient(to right, #667eea, #764ba2) border-box;
  box-shadow:
    0 0 0 3px rgba(102, 126, 234, 0.15),
    var(--shadow-md);
  transform: translateY(0);
}

/* Texto del proyecto seleccionado */
.custom-select-trigger .selected-text {
  flex: 1;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ícono de la flecha */
.custom-select-trigger .arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: var(--spacing-2);
  transition: transform var(--transition-base);
}

.custom-select-trigger.active .arrow {
  transform: rotate(180deg);
}

.custom-select-trigger .arrow svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-text-secondary);
  stroke-width: 2;
}

/* Indicador de punto activo */
.custom-select-trigger::after {
  content: '●';
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: #667eea;
  opacity: 0.6;
  pointer-events: none;
}

.custom-select-trigger.active::after {
  opacity: 0;
}

/* Dropdown menu (lista de opciones) */
.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  max-height: 400px;
  overflow: hidden;
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base);
}

.custom-select-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Scrollbar personalizado para el dropdown - Ahora movido a .custom-select-options-container */

/* Opciones individuales del dropdown */
.custom-select-option {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid var(--color-border-subtle);
  position: relative;
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.custom-select-option:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Hover en opciones */
.custom-select-option:hover {
  background: linear-gradient(135deg, #F4F4F5 0%, #E4E4E7 100%);
  padding-left: 20px;
}

/* Opción seleccionada - Gradiente púrpura profesional */
.custom-select-option.selected {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-semibold);
  padding-left: 20px;
}

.custom-select-option.selected:hover {
  background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
}

/* Checkmark para opción seleccionada */
.custom-select-option.selected::before {
  content: '✓';
  position: absolute;
  left: 8px;
  font-size: 14px;
  font-weight: bold;
  opacity: 0.9;
}

/* Texto de la opción */
.custom-select-option .option-text {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: inherit;
}

.custom-select-option.selected .option-text {
  font-weight: var(--font-weight-semibold);
}

/* Separador para la opción TODOS */
.custom-select-option.separator {
  border-top: 2px solid var(--color-border);
  margin-top: 4px;
  padding-top: 16px;
}

/* Opción TODOS (Consolidado) - Estilo especial */
.custom-select-option.todos-option {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-bold);
  border-top: 2px solid var(--color-border);
  margin-top: 4px;
}

.custom-select-option.todos-option:hover {
  background: linear-gradient(135deg, #5568d3 0%, #653a8a 100%);
  padding-left: 20px;
}

.custom-select-option.todos-option.selected {
  background: linear-gradient(135deg, #4a52c0 0%, #5a2d77 100%);
}

/* Emoji en opciones */
.custom-select-option .option-emoji {
  margin-right: var(--spacing-2);
  font-size: 16px;
}

/* Animación de entrada para las opciones */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.custom-select-dropdown.active .custom-select-option {
  animation: slideIn var(--transition-fast) ease-out forwards;
}

.custom-select-dropdown.active .custom-select-option:nth-child(1) {
  animation-delay: 0ms;
}

.custom-select-dropdown.active .custom-select-option:nth-child(2) {
  animation-delay: 20ms;
}

.custom-select-dropdown.active .custom-select-option:nth-child(3) {
  animation-delay: 40ms;
}

.custom-select-dropdown.active .custom-select-option:nth-child(4) {
  animation-delay: 60ms;
}

.custom-select-dropdown.active .custom-select-option:nth-child(5) {
  animation-delay: 80ms;
}

.custom-select-dropdown.active .custom-select-option:nth-child(n+6) {
  animation-delay: 100ms;
}

/* Búsqueda dentro del dropdown */
.custom-select-search {
  position: relative;
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
}

.custom-select-search .search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  stroke: var(--color-text-tertiary);
  pointer-events: none;
  z-index: 1;
}

.custom-select-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  font-size: var(--font-size-sm);
  font-family: var(--font-family-primary);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  transition: all var(--transition-base);
}

.custom-select-search-input::placeholder {
  color: var(--color-text-tertiary);
}

.custom-select-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.08);
}

.custom-select-search-input:focus ~ .search-icon {
  stroke: var(--color-primary);
}

/* Botón de limpiar búsqueda */
.custom-select-search-clear {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--color-text-tertiary);
  color: var(--color-bg-primary);
  border-radius: 50%;
  font-size: 16px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.custom-select-search-clear:hover {
  background: var(--color-text-primary);
  transform: translateY(-50%) scale(1.1);
}

/* Contenedor de opciones */
.custom-select-options-container {
  max-height: 320px;
  overflow-y: auto;
}

/* Scrollbar del contenedor de opciones */
.custom-select-options-container::-webkit-scrollbar {
  width: 8px;
}

.custom-select-options-container::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

.custom-select-options-container::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, #667eea, #764ba2);
  border-radius: 4px;
}

.custom-select-options-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(to bottom, #5568d3, #653a8a);
}

/* Highlight de búsqueda */
.search-highlight {
  background: linear-gradient(135deg, #FFEB3B 0%, #FFC107 100%);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  padding: 2px 4px;
  border-radius: 3px;
}

/* Sin resultados */
.custom-select-no-results {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--font-size-sm);
}

/* Compatibilidad con header oscuro */
.header.header-dark-bg .custom-select-trigger {
  background:
    linear-gradient(rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.1)) padding-box,
    linear-gradient(to right, #667eea, #764ba2) border-box;
  color: var(--color-text-inverse);
}

.header.header-dark-bg .custom-select-trigger .selected-text {
  color: var(--color-text-inverse);
}

.header.header-dark-bg .custom-select-trigger:hover {
  background:
    linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.15)) padding-box,
    linear-gradient(to right, #5568d3, #653a8a) border-box;
}

/* Compatibilidad con header claro */
.header.header-light-bg .custom-select-trigger {
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(250, 250, 250, 0.95)) padding-box,
    linear-gradient(to right, #667eea, #764ba2) border-box;
}

/* Animación de cambio de proyecto */
@keyframes project-change {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

.custom-project-selector.changing .custom-select-trigger {
  animation: project-change 300ms cubic-bezier(0.4, 0, 0.2, 1);
}
