/**
 * Custom Dropdown Component
 * Replaces native select elements with styled dropdowns
 * Based on Figma node: 2166-54289
 *
 * @package Momsides
 */

/* ==========================================================================
   Custom Dropdown Container
   ========================================================================== */

.custom-dropdown {
  position: relative;
  width: 100%;
}

/* ==========================================================================
   Dropdown Trigger (visible button)
   ========================================================================== */

.custom-dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 8px 16px;
  background-color: var(--color-bg, #f6f6f6);
  border: 1px solid var(--color-text-muted, #a6a6a6);
  border-radius: 10px;
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text-muted, #a6a6a6);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  text-align: left;
}

.custom-dropdown__trigger:hover {
  border-color: var(--color-border, #DBDBDB);
}

.custom-dropdown__trigger:focus {
  outline: none;
  border-color: var(--color-accent, #8fb56c);
}

/* When dropdown is open */
.custom-dropdown.is-open .custom-dropdown__trigger {
  border-color: var(--color-accent-soft, #CCDEB8);
  background-color: var(--color-bg, #f6f6f6);
}

/* When value is selected (not placeholder) */
.custom-dropdown.has-value .custom-dropdown__trigger {
  color: var(--color-text, #303030);
}

/* Trigger text */
.custom-dropdown__value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dropdown arrow icon */
.custom-dropdown__arrow {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.custom-dropdown__arrow svg {
  width: 12px;
  height: 12px;
}

.custom-dropdown.is-open .custom-dropdown__arrow {
  transform: rotate(180deg);
}

.custom-dropdown__arrow svg path {
  stroke: var(--color-text-muted, #a6a6a6);
}

.custom-dropdown.has-value .custom-dropdown__arrow svg path {
  stroke: var(--color-text, #303030);
}

/* ==========================================================================
   Dropdown Menu (options list)
   ========================================================================== */

.custom-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 0;
  overflow: hidden;
  background-color: var(--color-surface, #ffffff);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: max-height 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
}

.custom-dropdown.is-open .custom-dropdown__menu {
  max-height: 300px;
  overflow-y: auto;
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   Dropdown Options
   ========================================================================== */

.custom-dropdown__option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 20px;
  color: var(--color-text-secondary, #4d4d4d);
  background-color: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease;
}

.custom-dropdown__option:hover,
.custom-dropdown__option:focus {
  background-color: var(--color-bg, #f6f6f6);
  outline: none;
}

.custom-dropdown__option.is-selected {
  background-color: var(--color-bg, #f6f6f6);
  color: var(--color-text, #303030);
  font-weight: 500;
}

/* ==========================================================================
   Hidden native select (for form submission)
   ========================================================================== */

.custom-dropdown__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 767px) {
  .custom-dropdown__menu {
    max-height: 200px;
  }
  
  .custom-dropdown.is-open .custom-dropdown__menu {
    max-height: 200px;
  }
}
