/* ========================================
   TRAMACO - SELECT PERSONALIZADO
   Solución definitiva para dropdowns
======================================== */

/* Ocultar el select nativo */
.tramaco-custom-select-wrapper {
  position: relative;
  width: 100%;
}

.tramaco-custom-select-wrapper select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* Contenedor del select personalizado */
.tramaco-custom-select {
  position: relative;
  width: 100%;
  cursor: pointer;
  user-select: none;
  display: block;
}

/* Asegurar ancho completo en form-group */
.form-group .tramaco-custom-select-wrapper,
.form-group .tramaco-custom-select {
  width: 100%;
  display: block;
}

/* Botón del select (lo que se ve cerrado) */
.tramaco-custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: linear-gradient(to bottom, #ffffff, #fafbfc);
  font-size: 14px;
  font-weight: 600;
  color: #2d2d2d;
  transition: all 0.25s ease;
  box-sizing: border-box;
  min-height: 48px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.tramaco-custom-select-trigger:hover {
  border-color: #94a3b8;
  background: linear-gradient(to bottom, #ffffff, #f8fafc);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.tramaco-custom-select.open .tramaco-custom-select-trigger {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Texto del select */
.tramaco-custom-select-text {
  flex: 1;
  white-space: normal;
  word-wrap: break-word;
  overflow: visible;
  text-align: left;
  color: #2d2d2d;
  line-height: 1.3;
}

.tramaco-custom-select-text.placeholder {
  color: #888;
  font-weight: 500;
}

/* Flecha del select */
.tramaco-custom-select-arrow {
  width: 24px;
  height: 24px;
  margin-left: 12px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.tramaco-custom-select.open .tramaco-custom-select-arrow {
  transform: rotate(180deg);
}

.tramaco-custom-select-arrow svg {
  width: 100%;
  height: 100%;
  stroke: #2d2d2d;
  stroke-width: 2;
}

/* Lista de opciones (dropdown) */
.tramaco-custom-select-options {
  position: fixed;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
  max-height: 280px;
  overflow-y: auto;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  min-width: 220px;
}

.tramaco-custom-select.open .tramaco-custom-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Dropdown abierto hacia arriba */
.tramaco-custom-select-options.open-upward {
  transform: translateY(10px);
}

.tramaco-custom-select.open .tramaco-custom-select-options.open-upward {
  transform: translateY(0);
}

/* Opción individual */
.tramaco-custom-select-option {
  padding: 12px 16px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.tramaco-custom-select-option:hover {
  background: #f1f5f9;
  border-left-color: #3b82f6;
  color: #1e40af;
}

.tramaco-custom-select-option.selected {
  background: linear-gradient(to right, #eff6ff, #f8fafc);
  color: #1e40af;
  font-weight: 600;
  border-left-color: #3b82f6;
}

.tramaco-custom-select-option:first-child {
  border-radius: 8px 8px 0 0;
}

.tramaco-custom-select-option:last-child {
  border-radius: 0 0 8px 8px;
}

/* Scrollbar personalizado para opciones */
.tramaco-custom-select-options::-webkit-scrollbar {
  width: 6px;
}

.tramaco-custom-select-options::-webkit-scrollbar-track {
  background: #f8fafc;
  border-radius: 0 12px 12px 0;
}

.tramaco-custom-select-options::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.tramaco-custom-select-options::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Estado deshabilitado */
.tramaco-custom-select.disabled .tramaco-custom-select-trigger {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f5f5f5;
}

/* Animación de carga */
.tramaco-custom-select.loading .tramaco-custom-select-arrow {
  animation: rotate 1s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .tramaco-custom-select-trigger {
    font-size: 15px;
    padding: 12px 14px;
    min-height: 48px;
  }

  .tramaco-custom-select-option {
    padding: 12px 14px;
    font-size: 14px;
  }

  .tramaco-custom-select-options {
    max-height: 240px;
  }
}
