/* ===== CUSTOM DROPDOWN ===== */
.custom-select {
  position: relative;
  display: inline-block;
  font-family: inherit;
}
.custom-select > select { display: none; }

/* --- Trigger button --- */
.custom-select__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .6rem 1rem;
  background: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: .75rem;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  white-space: nowrap;
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
}
.custom-select__trigger:hover {
  border-color: var(--green-400);
}
.custom-select__trigger:focus,
.custom-select.open .custom-select__trigger {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

/* Placeholder style (no value selected) */
.custom-select__trigger--placeholder {
  color: var(--text-muted);
}

/* Arrow icon */
.custom-select__arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  color: var(--text-muted);
}
.custom-select.open .custom-select__arrow {
  transform: rotate(180deg);
}

/* --- Options panel --- */
.custom-select__options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  max-width: calc(100vw - 1rem);
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: .75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);
  z-index: 1000;
  padding: .35rem;
  opacity: 0;
  transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity .2s cubic-bezier(.4,0,.2,1), transform .2s cubic-bezier(.4,0,.2,1);
}
.custom-select.open .custom-select__options {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Drop right-to-left when near right edge */
.custom-select.drop-left .custom-select__options {
  left: auto;
  right: 0;
}

/* Drop upward when near bottom */
.custom-select.drop-up .custom-select__options {
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateY(8px) scale(.97);
}
.custom-select.drop-up.open .custom-select__options {
  transform: translateY(0) scale(1);
}

/* Scrollbar */
.custom-select__options::-webkit-scrollbar { width: 5px; }
.custom-select__options::-webkit-scrollbar-track { background: transparent; }
.custom-select__options::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* --- Individual option --- */
.custom-select__option {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem;
  border-radius: .5rem;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.custom-select__option:hover {
  background: var(--green-50);
  color: var(--green-700);
}
.custom-select__option.selected {
  background: var(--green-100);
  color: var(--green-700);
  font-weight: 600;
}
.custom-select__option.disabled {
  color: var(--text-muted);
  opacity: .5;
  pointer-events: none;
}

/* Check mark for selected option */
.custom-select__check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0;
  color: var(--green-600);
  transition: opacity .15s;
}
.custom-select__option.selected .custom-select__check {
  opacity: 1;
}

/* --- Context-specific overrides --- */

/* Catalog sort dropdown */
.catalog-topbar__actions .custom-select__trigger {
  padding: .75rem 1rem;
  border-width: 1px;
}

/* Contact form */
.contact-form .custom-select {
  width: 100%;
}
.contact-form .custom-select__trigger {
  width: 100%;
  padding: .75rem 1rem;
  border-radius: 12px;
}
.contact-form .custom-select__options {
  width: 100%;
}
.contact-form .custom-select__trigger:focus,
.contact-form .custom-select.open .custom-select__trigger {
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
  transform: translateY(-1px);
}

/* Submit form (prijava) */
.submit-form .custom-select {
  width: 100%;
}
.submit-form .custom-select__trigger {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: .5rem;
  font-size: .88rem;
}
.submit-form .custom-select__options {
  width: 100%;
}

/* Admin forms */
.admin-filter-bar .custom-select__trigger {
  padding: .5rem .75rem;
  font-size: .88rem;
  border-radius: .5rem;
  background: var(--input-bg);
}
.admin-settings-form .custom-select {
  width: 100%;
}
.admin-settings-form .custom-select__trigger {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: .5rem;
  font-size: .88rem;
}
.admin-settings-form .custom-select__options {
  width: 100%;
}

/* --- Dark theme adjustments --- */
[data-theme="dark"] .custom-select__options {
  box-shadow: 0 8px 24px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.2);
}

/* --- Responsive --- */
@media (max-width: 870px) {
  .catalog-topbar__actions .custom-select__trigger {
    height: 2.75rem;
    padding: 0 .75rem;
    font-size: .85rem;
  }
}
