/* Needs custom select — progressive enhancement of <select> */

select.cs-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  flex: 0 0 0 !important;
  max-width: 1px !important;
}

.cs-wrap {
  display: inline-block;
  position: relative;
  width: auto !important;
  flex: 0 0 auto !important;
  max-width: 100%;
  vertical-align: middle;
  font-family: inherit;
}

.cs-wrap.is-open {
  z-index: 1000;
}

.cs-wrap.cs-block,
.cs-wrap.cs-full {
  display: block;
  width: 100% !important;
}

.cs-wrap.cs-full .cs-trigger {
  width: 100%;
  max-width: none;
}

.cs-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  background: #0f172a;
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.cs-trigger:hover {
  border-color: #c9a84c;
}

.cs-trigger:focus {
  outline: none;
}

.cs-trigger:focus-visible {
  outline: 2px solid #c9a84c;
  outline-offset: 2px;
  border-color: #c9a84c;
}

.cs-trigger.is-placeholder .cs-trigger-label {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

.cs-trigger-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-trigger-ico {
  flex-shrink: 0;
  color: #c9a84c;
  font-size: 12px;
  transition: transform 0.2s ease;
}

.cs-wrap.is-open .cs-trigger-ico {
  transform: rotate(180deg);
}

.cs-wrap.is-open .cs-trigger {
  border-color: #c9a84c;
}

/* Variante compacte (headers de carte, toolbars serrées) */
.cs-wrap.cs-sm .cs-trigger {
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  min-width: 80px;
  border-radius: 10px;
  gap: 8px;
}

.cs-wrap.cs-sm .cs-menu {
  left: auto;
  right: 0;
}

.cs-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  min-width: 100%;
  width: max-content;
  max-width: 260px;
  box-sizing: border-box;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #111827;
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  z-index: 1001;
  max-height: min(320px, 60vh);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;
}

.cs-wrap.is-open .cs-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.cs-wrap.is-up .cs-menu {
  top: auto;
  bottom: calc(100% + 6px);
  transform: translateY(6px);
}

.cs-wrap.is-open.is-up .cs-menu {
  transform: translateY(0);
}

.cs-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cs-option:hover,
.cs-option.is-active {
  background: rgba(201, 168, 76, 0.12);
  color: #ffffff;
}

.cs-option.is-selected {
  color: #c9a84c;
  font-weight: 600;
}

.cs-option-check {
  flex-shrink: 0;
  color: #c9a84c;
  font-size: 12px;
  opacity: 0;
}

.cs-option.is-selected .cs-option-check {
  opacity: 1;
}

.cs-option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .cs-wrap.cs-full {
    width: 100% !important;
  }
  .cs-trigger {
    min-height: 44px;
    height: 44px;
  }
  .cs-wrap.cs-sm .cs-trigger {
    height: 34px;
    min-height: 34px;
  }
  .cs-option {
    min-height: 44px;
    padding: 12px 14px;
  }
}

/* Mode clair : garder le look sombre Needs (contraste sur fond beige) */
html.needs-light .cs-trigger,
body.light-mode .cs-trigger {
  background: #0f172a;
  color: #ffffff;
  border-color: rgba(201, 168, 76, 0.35);
}
html.needs-light .cs-menu,
body.light-mode .cs-menu {
  background: #111827;
  border-color: rgba(201, 168, 76, 0.25);
}
