// ============================================
// Dropdown Component
// ============================================

@use "variables" as *;

// Dropdown container
.jbs-dropdown {
  position: relative;
}

// Dropdown toggle button
.jbs-dropdown-toggle {
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  
  &::after {
    display: inline-block;
    margin-left: 0.255em;
    vertical-align: 0.255em;
    content: "";
    border-top: 0.3em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
  }
  
  &:focus {
    outline: 0;
  }
  
  &[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }
}

// Dropdown menu (the actual dropdown panel)
.jbs-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0.125rem 0 0;
  font-size: 1rem;
  color: $text-dark;
  text-align: left;
  list-style: none;
  background-color: $text-white;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
  
  &.show {
    display: block;
  }
}

// Dropdown menu alignment
.jbs-dropdown-menu-end {
  right: 0;
  left: auto;
}

.jbs-dropdown-menu-start {
  right: auto;
  left: 0;
}

// Dropdown items
.jbs-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.25rem 1rem;
  clear: both;
  font-weight: 400;
  color: $text-dark;
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
  
  &:hover,
  &:focus {
    color: #1e2125;
    background-color: #f8f9fa;
  }
  
  &:active {
    color: $text-white;
    text-decoration: none;
    background-color: #0d6efd;
  }
  
  &.active {
    color: $text-white;
    text-decoration: none;
    background-color: #0d6efd;
  }
  
  &.disabled,
  &:disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: transparent;
  }
}

// Dropdown divider
.jbs-dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
}

// Dropdown header
.jbs-dropdown-header {
  display: block;
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  font-size: 0.875rem;
  color: #6c757d;
  white-space: nowrap;
}

// Dropdown text
.jbs-dropdown-text {
  display: block;
  padding: 0.25rem 1rem;
  color: $text-dark;
}

// Dark dropdown variant
.jbs-dropdown-menu-dark {
  color: #dee2e6;
  background-color: #343a40;
  border-color: rgba(0, 0, 0, 0.15);
  
  .jbs-dropdown-item {
    color: #dee2e6;
    
    &:hover,
    &:focus {
      color: $text-white;
      background-color: rgba(255, 255, 255, 0.15);
    }
    
    &.active {
      color: $text-white;
      background-color: #0d6efd;
    }
    
    &.disabled,
    &:disabled {
      color: #adb5bd;
    }
  }
  
  .jbs-dropdown-divider {
    border-color: rgba(0, 0, 0, 0.15);
  }
  
  .jbs-dropdown-header {
    color: #adb5bd;
  }
}

// Responsive behavior for mobile
@media (max-width: 576px) {
  .jbs-dropdown-menu {
    min-width: 100%;
  }
}
