.snake-menu__container {
  position: relative;
  display: inline-block;
}

.snake-menu__trigger {
  cursor: pointer;
}

.snake-menu {
  position: absolute;
  z-index: 1000;
  min-width: 200px;
  background-color: #1f1d20;
  border: 1px solid #3a3a3a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity var(--transition-fast),
    transform var(--transition-fast);
  pointer-events: none;
}

.snake-menu--open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Placement */
.snake-menu--bottom-start {
  top: 100%;
  left: 0;
  margin-top: 4px;
}

.snake-menu--bottom-end {
  top: 100%;
  right: 0;
  margin-top: 4px;
}

.snake-menu--top-start {
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
}

.snake-menu--top-end {
  bottom: 100%;
  right: 0;
  margin-bottom: 4px;
}

.snake-menu--right-start {
  left: 100%;
  top: 0;
  margin-left: 4px;
}

.snake-menu--left-start {
  right: 100%;
  top: 0;
  margin-right: 4px;
}

/* Size variants */
.snake-menu--small {
  min-width: 150px;
}

.snake-menu--small .snake-menu__item {
  padding: 6px 12px;
  font-size: var(--font-size-sm);
}

.snake-menu--medium {
  min-width: 200px;
}

.snake-menu--medium .snake-menu__item {
  padding: 8px 16px;
  font-size: var(--font-size-base);
}

.snake-menu--large {
  min-width: 250px;
}

.snake-menu--large .snake-menu__item {
  padding: 10px 20px;
  font-size: var(--font-size-base);
}

/* Menu content */
.snake-menu__content {
  padding: var(--spacing-xs) 0;
  max-height: 400px;
  overflow-y: auto;
}

/* Menu item */
.snake-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 16px;
  background-color: transparent;
  border: none;
  color: var(--color-text-primary);
  font-family: var(--font-family);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.snake-menu__item:hover:not(.snake-menu__item--disabled) {
  background-color: rgba(189, 189, 189, 0.1);
  color: #ffffff;
}

.snake-menu__item:active:not(.snake-menu__item--disabled) {
  background-color: rgba(189, 189, 189, 0.15);
}

.snake-menu__item--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.snake-menu__item--danger {
  color: var(--color-danger);
}

.snake-menu__item--danger:hover:not(.snake-menu__item--disabled) {
  background-color: rgba(255, 85, 85, 0.1);
  color: var(--color-danger);
}

/* Item elements */
.snake-menu__item-icon {
  margin-right: var(--spacing-sm);
  flex-shrink: 0;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-menu__item-label {
  flex: 1;
  text-align: left;
}

.snake-menu__item-shortcut {
  margin-left: var(--spacing-lg);
  font-size: var(--font-size-sm);
  color: #8e8e90;
  font-family: var(--font-family-mono);
}

.snake-menu__item-arrow {
  margin-left: var(--spacing-sm);
  font-size: 10px;
  color: #8e8e90;
  transition: transform var(--transition-fast);
}

.snake-menu__item--submenu-open .snake-menu__item-arrow {
  transform: rotate(90deg);
}

/* Divider */
.snake-menu__divider {
  height: 1px;
  background-color: #3a3a3a;
  margin: var(--spacing-xs) 0;
}

/* Submenu */
.snake-menu__submenu {
  position: absolute;
  left: 100%;
  top: -4px;
  margin-left: 4px;
  min-width: 180px;
  background-color: #1f1d20;
  border: 1px solid #3a3a3a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding: var(--spacing-xs) 0;
  opacity: 0;
  transform: translateX(-8px);
  animation: snake-menu-submenu-in var(--transition-fast) ease-out forwards;
}

.snake-menu__submenu--nested {
  left: 100%;
  margin-left: 2px;
}

@keyframes snake-menu-submenu-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Arrow */
.snake-menu__arrow {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: #1f1d20;
  border: 1px solid #3a3a3a;
  transform: rotate(45deg);
}

.snake-menu--bottom-start .snake-menu__arrow,
.snake-menu--bottom-end .snake-menu__arrow {
  top: -5px;
  border-right: none;
  border-bottom: none;
}

.snake-menu--bottom-start .snake-menu__arrow {
  left: 16px;
}

.snake-menu--bottom-end .snake-menu__arrow {
  right: 16px;
}

.snake-menu--top-start .snake-menu__arrow,
.snake-menu--top-end .snake-menu__arrow {
  bottom: -5px;
  border-left: none;
  border-top: none;
}

.snake-menu--top-start .snake-menu__arrow {
  left: 16px;
}

.snake-menu--top-end .snake-menu__arrow {
  right: 16px;
}

/* Corner decorations */
.snake-menu__corner {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid #3a3a3a;
  pointer-events: none;
}

.snake-menu__corner--top-left {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.snake-menu__corner--top-right {
  top: -1px;
  right: -1px;
  border-left: none;
  border-bottom: none;
}

.snake-menu__corner--bottom-left {
  bottom: -1px;
  left: -1px;
  border-right: none;
  border-top: none;
}

.snake-menu__corner--bottom-right {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

/* Scrollbar styling */
.snake-menu__content::-webkit-scrollbar {
  width: 4px;
}

.snake-menu__content::-webkit-scrollbar-track {
  background: transparent;
}

.snake-menu__content::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 0;
}

.snake-menu__content::-webkit-scrollbar-thumb:hover {
  background: #4a4a4a;
}

/* Focus styles */
.snake-menu__item:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(189, 189, 189, 0.3);
}
