/* Multi-Select Dropdowns for Elementor Forms */

/* Defaults. The settings page overrides these with an inline rule. */
.emsd-wrap {
  --emsd-accent: var(--e-global-color-accent, #28a745);
  --emsd-panel-bg: #ffffff;
  --emsd-text: #1f2124;
  --emsd-checked-bg: color-mix(in srgb, var(--emsd-accent) 12%, var(--emsd-panel-bg));
  --emsd-check-radius: 4px;
  --emsd-font-family: inherit;
  --emsd-font-size: inherit;
  --emsd-font-weight: inherit;
  --emsd-columns: 2;

  /* Not positioned on purpose: Elementor's arrow sits in the wrapper behind
     this element in the markup and must paint on top of the field. */
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
}

/* Elementor's select wrapper is the anchor for the hidden select, the arrow
   and the open panel. */
.emsd-host { position: relative; }

/* The real select stays in the form (for submission and validation) but is
   visually hidden along the bottom edge so browser messages point at the field. */
.emsd-host select.emsd-native {
  position: absolute !important;
  left: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* ---------- closed field ---------- */
/* Low-specificity fallbacks; Elementor's form styles take over when present. */
.emsd-toggle {
  min-height: 40px;
  padding: 5px 14px;
  border: 1px solid #69727d;
  border-radius: 3px;
}
.emsd-wrap .emsd-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: auto;
  box-sizing: border-box;
  /* The toggle sits inside Elementor's field wrapper, which already carries the
     form typography. Inherit so em-based sizes are not applied twice. */
  font-size: inherit !important;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.emsd-wrap .emsd-toggle:focus-visible {
  outline: 2px solid var(--emsd-accent);
  outline-offset: 1px;
}
.emsd-wrap .emsd-toggle.emsd-invalid { border-color: #d9534f; }
.emsd-wrap .emsd-summary { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.emsd-wrap .emsd-is-empty .emsd-summary { opacity: .65; }
/* Room for the arrow, which is Elementor's own icon when one is available. */
.emsd-wrap .emsd-toggle { padding-right: 30px !important; }
.emsd-wrap.emsd-native-caret .emsd-caret { display: none; }
/* Fallback arrow for forms with no other select to copy the icon from. */
.emsd-wrap .emsd-caret {
  position: absolute;
  top: 50%;
  right: 11px;
  width: 0;
  height: 0;
  margin-top: -3px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  pointer-events: none;
}

/* ---------- panel ---------- */
.emsd-wrap .emsd-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 9999;
  box-sizing: border-box;
  background: var(--emsd-panel-bg);
  color: var(--emsd-text);
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  font-family: var(--emsd-font-family);
  font-size: var(--emsd-font-size);
  font-weight: var(--emsd-font-weight);
  line-height: 1.3;
  text-align: left;
}
.emsd-wrap .emsd-panel[hidden],
.emsd-wrap .emsd-item[hidden],
.emsd-wrap .emsd-empty-msg[hidden] { display: none !important; }

.emsd-wrap .emsd-search { padding: 10px; border-bottom: 1px solid rgba(0, 0, 0, .08); }
.emsd-wrap .emsd-search .emsd-search-input,
.emsd-wrap .emsd-search .emsd-search-input:focus {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 8px 12px;
  background: #fff;
  color: #1f2124;
  border: 1px solid rgba(0, 0, 0, .25);
  border-radius: 6px;
  box-shadow: none;
  font: inherit;
}
.emsd-wrap .emsd-search .emsd-search-input:focus { border-color: var(--emsd-accent); outline: none; }

.emsd-wrap .emsd-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  max-height: 260px;
  padding: 10px;
  overflow: auto;
  overscroll-behavior: contain;
}
@media (min-width: 720px) {
  .emsd-wrap .emsd-list { grid-template-columns: repeat(var(--emsd-columns), minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .emsd-wrap .emsd-list { max-height: 220px; }
}

.emsd-wrap .emsd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.emsd-wrap .emsd-item:hover { border-color: rgba(0, 0, 0, .3); }
.emsd-wrap .emsd-item.emsd-checked { background: var(--emsd-checked-bg); border-color: var(--emsd-accent); }
.emsd-wrap .emsd-item.emsd-disabled { opacity: .5; cursor: not-allowed; }
.emsd-wrap .emsd-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.emsd-wrap .emsd-item .emsd-check {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  background: #fff center / 12px 12px no-repeat;
  border: 2px solid #8a939d;
  border-radius: var(--emsd-check-radius);
  box-shadow: none;
  cursor: pointer;
}
.emsd-wrap .emsd-item .emsd-check:checked {
  background-color: var(--emsd-accent);
  border-color: var(--emsd-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.2l2.6 2.6L10 3.4' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.emsd-wrap .emsd-item .emsd-check:focus-visible { outline: 2px solid var(--emsd-accent); outline-offset: 2px; }

.emsd-wrap .emsd-empty-msg { padding: 14px; text-align: center; opacity: .7; }

.emsd-wrap .emsd-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(0, 0, 0, .08);
}
/* Spelled out for every state so theme button styles can't leak in. */
.emsd-wrap .emsd-actions .emsd-btn,
.emsd-wrap .emsd-actions .emsd-btn:hover,
.emsd-wrap .emsd-actions .emsd-btn:focus,
.emsd-wrap .emsd-actions .emsd-btn:active {
  width: auto;
  margin: 0;
  padding: 8px 16px;
  background: #fff;
  color: #1f2124;
  border: 1px solid rgba(0, 0, 0, .25);
  border-radius: 8px;
  box-shadow: none;
  font: inherit;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.emsd-wrap .emsd-actions .emsd-btn:hover { background: #f3f5f7; }
.emsd-wrap .emsd-actions .emsd-btn:focus-visible { outline: 2px solid var(--emsd-accent); outline-offset: 2px; }
.emsd-wrap .emsd-actions .emsd-clear:disabled { opacity: .5; cursor: default; }
.emsd-wrap .emsd-actions .emsd-done,
.emsd-wrap .emsd-actions .emsd-done:hover,
.emsd-wrap .emsd-actions .emsd-done:focus,
.emsd-wrap .emsd-actions .emsd-done:active {
  background: var(--emsd-accent);
  border-color: var(--emsd-accent);
  color: #fff;
}
.emsd-wrap .emsd-actions .emsd-done:hover { filter: brightness(.94); }
