/* Every row below is free to wrap: the widget is dropped into sidebars and
   input grids of any width, and controls that cannot shrink past a fixed width
   spill outside the panel instead of reflowing. */
.multi-color-picker {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  font-size: 13px;
  box-sizing: border-box;
  min-width: 0;
}

.multi-color-picker *,
.multi-color-picker *::before,
.multi-color-picker *::after {
  box-sizing: border-box;
}

.multi-color-picker .mc-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.multi-color-picker .mc-top > .control-label {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.multi-color-picker .mc-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
  flex: 1 1 auto;
  min-width: 0;
}

/* Grows into the space available and shrinks rather than pushing the buttons
   out of the panel; the buttons wrap to their own line once it cannot. */
.multi-color-picker .selectize-control.mc-palette-select {
  flex: 1 1 130px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

.multi-color-picker .selectize-control.mc-palette-select .selectize-input {
  min-height: 30px;
  min-width: 0;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Kept beside the palette selector while it fits and wrapped onto its own line
   when it does not, rather than hanging off the edge of the panel. */
.multi-color-picker .mc-button-group {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 4px;
}

.multi-color-picker .mc-button-group .mc-button {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}

.multi-color-picker .mc-palette-select {
  flex: 1 1 130px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  padding: 3px 6px;
  font-size: 12px;
}

.multi-color-picker .mc-button {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid #ced4da;
  background: #f8f9fa;
  color: #333333;
  border-radius: 4px;
  cursor: pointer;
}

.multi-color-picker .mc-button:hover {
  background: #e9ecef;
}

.multi-color-picker.is-plain {
  border: none;
  padding: 0;
  background: transparent;
}

.multi-color-picker .mc-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.multi-color-picker .mc-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #ced4da;
  cursor: pointer;
}

.multi-color-picker .mc-swatch:hover {
  outline: 1px solid #6c757d;
}

.multi-color-picker .mc-color-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Label, swatch and hex field on one line while they fit; the hex field drops
   below them when the row gets tight, and the swatch follows if it gets
   tighter still. */
.multi-color-picker .mc-color-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 6px 8px;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  cursor: pointer;
}

.multi-color-picker .mc-color-row.is-active {
  border-color: #94bde7;
  box-shadow: 0 0 0 2px rgba(52, 144, 220, 0.18);
}

/* Group names come from the data and can be long, so they wrap rather than
   run underneath the controls. */
.multi-color-picker .mc-group-label {
  flex: 1 1 4.5em;
  min-width: 0;
  font-weight: 600;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.multi-color-picker .mc-color-input {
  flex: 0 0 auto;
  width: 42px;
  height: 28px;
  padding: 0;
  border: 1px solid #ced4da;
  border-radius: 4px;
}

/* Shrinks (and eventually wraps) with the row, but does not grow, so roomy
   layouts keep the size they had. */
.multi-color-picker .mc-text-input {
  flex: 0 1 96px;
  width: auto;
  min-width: 5.5em;
  max-width: 100%;
  font-size: 12px;
}

.multi-color-picker .mc-palette-option,
.multi-color-picker .mc-selected-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.multi-color-picker .mc-palette-name {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 2px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

/* The selected palette's preview shrinks with the selector (its swatches are
   clipped) instead of holding the whole control open at a fixed width. The
   dropdown copy below is attached to <body> and keeps its comfortable size. */
.multi-color-picker .mc-palette-bar {
  display: flex;
  gap: 1px;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
}

.multi-color-picker .mc-option-swatch {
  flex: 1;
  min-width: 8px;
  height: 18px;
  box-sizing: border-box;
}

.multi-color-picker .selectize-control.mc-palette-select .selectize-input > div {
  padding: 2px 4px;
}

/* Dropdown lives outside the widget container; keep these unscoped */
.selectize-dropdown .option {
  padding: 0 !important;
}

.selectize-dropdown .selectize-dropdown-content {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selectize-dropdown .optgroup-header {
  font-size: 12px;
  font-weight: 700;
  color: #495057;
  padding: 4px 2px;
}

.selectize-dropdown .mc-palette-option {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.selectize-dropdown .mc-palette-name {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 2px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.selectize-dropdown .mc-palette-bar {
  display: flex;
  gap: 1px;
  flex: 1;
  min-width: 140px;
  align-items: center;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
}

.selectize-dropdown .mc-option-swatch {
  flex: 1;
  min-width: 8px;
  height: 18px;
  box-sizing: border-box;
}

.selectize-dropdown.mc-compact .selectize-dropdown-content {
  padding: 4px;
  gap: 4px;
}

.selectize-dropdown.mc-compact .mc-palette-bar {
  min-width: 120px;
  height: 16px;
}

.selectize-dropdown.mc-compact .mc-option-swatch {
  min-width: 7px;
  height: 16px;
}

.multi-color-picker.is-compact {
  padding: 6px;
  font-size: 11px;
}

.multi-color-picker.is-compact .mc-actions {
  gap: 2px;
}

.multi-color-picker.is-compact .selectize-control.mc-palette-select {
  flex-basis: 110px;
}

.multi-color-picker.is-compact .selectize-control.mc-palette-select .selectize-input {
  min-height: 26px;
  padding: 2px 4px;
  gap: 3px;
}

.multi-color-picker.is-compact .mc-palette-select {
  flex-basis: 110px;
  padding: 2px 5px;
}

.multi-color-picker.is-compact .mc-button-group {
  gap: 2px;
}

.multi-color-picker.is-compact .mc-button {
  padding: 2px 5px;
  font-size: 10px;
}

.multi-color-picker.is-compact .mc-color-row {
  gap: 5px;
  padding: 2px 4px;
}

.multi-color-picker.is-compact .mc-color-input {
  width: 32px;
  height: 18px;
  padding: 0;
}

.multi-color-picker.is-compact .mc-text-input {
  flex-basis: 70px;
  height: 18px;
  padding: 2px 4px;
  font-size: 10px;
  line-height: 1.1;
}

.multi-color-picker.is-compact .mc-palette-bar {
  height: 14px;
}

.selectize-dropdown .is-compact .mc-palette-bar {
  min-width: 110px;
  height: 14px;
}

.multi-color-picker.is-compact .mc-option-swatch,
.selectize-dropdown .is-compact .mc-option-swatch {
  min-width: 6px;
  height: 14px;
}
