/* =========================================================
   BOOWS Select (Dropdown)
   - rem statt px
   - nutzt BOOWS Variablen aus base.css / forms.css / theme.css
   - weiche Kanten, sanfte Schatten, klare Hover/Focus States
   ========================================================= */

/* optionale, komponenten-spezifische Defaults (mit Fallbacks) */
:root {
  --boows-select-radius: var(--boows-radius, 0.75rem);
  --boows-select-shadow: var(--boows-shadow, 0 0.25rem 0.75rem rgba(0,0,0,0.08));
  --boows-select-item-min-h: var(--boows-input-height, 2.8rem);
}

/* Container um Select + (optional) Value-Zone */
.boows-container {
  position: relative;
  display: flex;
  max-width: var(--boows-max-input-width, 26.25rem);
  width: 100%;
  box-sizing: border-box;
}

/* Floating label */
.boows-container.boows-floating-label .boows-select > .boows-select-item.placeholder {
  display: none !important;
}

.boows-container.boows-floating-label .boows-select-floating-label {
  position: absolute;
  left: var(--boows-select-padding-left, 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  transform-origin: left top;
  z-index: 1;
  max-width: calc(100% - 2.75rem);
  font-size: max(0.78rem, calc(var(--boows-font-size-base, 1rem) - 0.05rem));
  color: var(--boows-col-text-60);
  background: transparent;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: var(--boows-transition, 0.2s ease);
}

.boows-container.boows-floating-label.has-prefix .boows-select-floating-label {
  left: calc(var(--boows-select-padding-left, 0.75rem) + 2.5rem);
  max-width: calc(100% - 5.25rem);
}

.boows-container.boows-floating-label.has-suffix .boows-select-floating-label {
  max-width: calc(100% - 5.25rem);
}

.boows-container.boows-floating-label.has-prefix.has-suffix .boows-select-floating-label {
  max-width: calc(100% - 7.5rem);
}

.boows-container.boows-floating-label.has-value .boows-select-floating-label,
.boows-container.boows-floating-label:focus-within .boows-select-floating-label,
.boows-container.boows-floating-label .boows-select.opened + .boows-select-floating-label {
  top: 2px;
  transform: translateY(0);
  font-size: 0.75rem;
  color: var(--boows-col-text-40);
}
.boows-container.boows-floating-label .boows-select-floating-label .boows-form-optional {
  color: inherit;
}
.boows-container.boows-floating-label.has-value .boows-select-floating-label .boows-form-optional,
.boows-container.boows-floating-label:focus-within .boows-select-floating-label .boows-form-optional,
.boows-container.boows-floating-label .boows-select.opened + .boows-select-floating-label .boows-form-optional {
  color: var(--boows-col-text-30);
}

.boows-input-field.disabled .boows-container.boows-floating-label .boows-select-floating-label {
  color: var(--boows-col-text-60);
}

/* === Prefix & Suffix for Select === */
.boows-container > .field-prefix,
.boows-container > .field-suffix {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--boows-space-2, 0.75rem);
  font-weight: 600;
  font-size: var(--boows-font-size-base, 1rem);
  background: var(--boows-col-secondary);
  color: #fff;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  min-width: 2.5rem;
  height: var(--boows-input-height);
}
.boows-container > .field-prefix {
  border-radius: var(--boows-input-radius) 0 0 var(--boows-input-radius);
}
.boows-container > .field-suffix {
  border-radius: 0 var(--boows-input-radius) var(--boows-input-radius) 0;
}
.boows-container.has-prefix > .boows-select {
  border-radius: 0 var(--boows-input-radius) var(--boows-input-radius) 0;
}
.boows-container.has-suffix > .boows-select {
  border-radius: var(--boows-input-radius) 0 0 var(--boows-input-radius);
}
.boows-container.has-prefix.has-suffix > .boows-select {
  border-radius: 0;
}
/* No-bg variant */
.boows-container > .field-prefix.no-bg,
.boows-container > .field-suffix.no-bg {
  background: transparent;
  color: var(--boows-col-text-60);
  font-weight: 400;
}

.boows-container.use-native-on-mobile .boows-select-native,
.boows-container.use-native-on-mobile-alternative .boows-select-native {
  display: none;
}

@media (max-width: 720px) {
  .boows-container.use-native-on-mobile .boows-select-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    display: block;
    z-index: 2;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
  }
  .boows-container.use-native-on-mobile .boows-select-list {
    display: none !important;
  }
  .boows-container.use-native-on-mobile-alternative .boows-select-list {
    display: none !important;
  }
}

@media screen and (min-width: 721px) {
  .boows-container.use-native-on-mobile .boows-select-native {
    display: none;
  }
}

/* Trigger/Anzeige des Selects */
.boows-select {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  min-width: 6.25rem; /* ~100px */
  height: var(--boows-input-height, 2.8rem);
  line-height: var(--boows-input-height, 2.8rem);
  border: 1px solid var(--boows-input-border, #ccc);
  border-radius: var(--boows-select-radius);
  background: var(--boows-input-bg, #fff);
  color: var(--boows-col-text, #222);
  font-size: var(--boows-font-size-base, 1rem);
  cursor: pointer;
  padding: 0 2.25rem 0 var(--boows-select-padding-left, 0.75rem); /* Platz rechts fuer Icon */
  transition: border var(--boows-transition, 0.2s ease), box-shadow var(--boows-transition, 0.2s ease), background var(--boows-transition, 0.2s ease);
  max-width: var(--boows-max-input-width, 26.25rem);
}

.boows-select:hover {
  border-color: var(--boows-col-primary, #08a29a);
}

/* Override legacy hover styles from global inputs */
.boows-container .boows-select:hover {
  border: 1px solid var(--boows-col-primary, #08a29a);
}

.boows-select.opened,
.boows-select:focus-within {
  border-color: var(--boows-col-primary, #08a29a);
  box-shadow: 0 0 0 0.2rem rgba(var(--boows-col-primary-rgb, 8,162,154), 0.25);
  background: #fff;
}

.boows-select.disabled {
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
  border-color: var(--boows-input-border, #ccc);
  background: rgba(148, 163, 184, 0.15);
}

.boows-select.disabled .boows-select-icon {
  opacity: 0.55;
}

/* Keep full border on focus/open even if global styles apply */
.boows-container .boows-select.opened,
.boows-container .boows-select:focus-within {
  border: 1px solid var(--boows-col-primary, #08a29a);
  box-shadow: 0 0 0 0.2rem rgba(var(--boows-col-primary-rgb, 8,162,154), 0.25);
}

/* Spezieller, schmaler Select z.B. in Phone-Component */
.phone .boows-select {
  min-width: 6.25rem;
  max-width: 6.25rem;
  margin-right: var(--boows-space-1, 0.5rem);
  height: 2.8rem;
}

/* Pfeil/Icon innerhalb des Select-Triggers */
.boows-select .boows-select-icon {
  position: absolute;
  right: var(--boows-space-1, 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  user-select: none;
  transition: transform var(--boows-transition, 0.2s ease);
  pointer-events: none;
  line-height: 1;
}

.boows-select.opened .material-icons.boows-select-icon {
  transform: translateY(-50%) rotate(180deg);
}

/* Dropdown-Liste */
.boows-select-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 1000;
  display: none; /* per JS toggeln */
  min-width: 100%;
  max-width: var(--boows-max-input-width, 26.25rem);
  max-height: 16rem;
  overflow-y: auto;
  background: #fff;
  color: var(--boows-col-text, #222);
  border: 1px solid var(--boows-input-border, #ccc);
  border-radius: var(--boows-radius-dropdown, 8px);
  box-shadow: var(--boows-select-shadow);
  box-sizing: border-box;
}

/* Suchzeile oben in der Liste */
.boows-search-box {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--boows-col-bg, #f6f8f9);
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.boows-search-field {
  width: 100%;
  height: var(--boows-input-height, 2.8rem);
  line-height: var(--boows-input-height, 2.8rem);
  border: 1px solid var(--boows-input-border, #ccc);
  border-radius: var(--boows-radius, 0.75rem);
  background: #fff;
  padding: 0 0.75rem;
  box-sizing: border-box;
  font-size: var(--boows-font-size-base, 1rem);
  outline: none;
  transition: border var(--boows-transition, 0.2s ease), box-shadow var(--boows-transition, 0.2s ease);
}
.boows-search-field:focus {
  border-color: var(--boows-col-primary, #dfb843);
  box-shadow: 0 0 0 0.2rem rgba(var(--boows-col-primary-rgb, 223,184,67), 0.2);
}

/* Einträge in der Liste + "nicht gefunden" */
.boows-select-item,
.boows-not-found {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 2rem 0.6rem 1rem;
  min-height: var(--boows-select-item-min-h);
  line-height: 1.25;
  cursor: pointer;
  box-sizing: border-box;
  color: var(--boows-col-text, #222);
  background: transparent;
  transition: background var(--boows-transition, 0.2s ease), color var(--boows-transition, 0.2s ease);
  font-size: var(--boows-font-size-base, 1rem);
}

.boows-not-found {
  cursor: default;
  font-style: italic;
  color: var(--boows-col-text-light, #666);
  display: none; /* per JS sichtbar machen */
}

/* Mehrzeilige Items */
.multiline .boows-select-list .boows-select-item {
  min-height: var(--boows-select-item-min-h);
  padding: 0.5rem 1rem;
  line-height: 1.35;
}

.boows-container.multiline .boows-select-list .boows-select-item .item-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.boows-container.multiline .boows-select-list .boows-select-item .item-text .finf {
  font-weight: 600;
}

.boows-container.multiline .boows-select-list .boows-select-item .item-text .info {
  font-size: 0.86em;
  opacity: 0.85;
}

/* Hover/Active */
.boows-select-list .boows-select-item:hover {
  background: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.12);
}

/* Placeholder/Hint in Trigger oder Liste */
.boows-select-item.placeholder,
.boows-not-found {
  color: var(--boows-col-text-light, #666);
  padding: 0;
}

/* Markierung (Search-Highlight) */
.boows-select-item mark {
  background: var(--boows-col-accent, #D3D4D4);
  color: inherit;
}

/* Meta/Info-Text */
.boows-select-item .info {
  color: var(--boows-col-text-light, #666);
}

/* Textcontainer in Items (für Custom-Templates) */
.boows-select-item .item-text .custom-select-item {
  display: flex;
  align-items: center;
}
.boows-select-item .item-text .custom-select-item :not(mark) {
  margin-left: 0.5rem;
}

/* Wenn derselbe Text im Trigger kompakter laufen soll */
.boows-container:not(.phone) .boows-select-item .item-text {
  display: inline-flex;
  align-items: center;
  margin-right: 0.75rem;
  padding: 0.25rem 0;
}
.boows-container:not(.phone) .boows-select .boows-select-item .item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 0;
  padding: 0;
}

/* Ausgewählter Eintrag (in der Liste) */
.boows-select-item.selected {
  position: relative;
  background: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.15);
}
.boows-select-item.selected::after {
  content: 'check';
  position: absolute;
  right: 0.5rem;
  top: 0.6rem;
  font-family: 'Material Icons';
  font-size: 1rem;
  height: 1.8rem;
  width: 1.8rem;
  line-height: 1.8rem;
  text-align: center;
  border-radius: 50%;
  background: #fff;
  color: var(--boows-col-primary, #dfb843);
}

/* Wenn im Trigger ein .info steht, dort neutral darstellen */
.boows-select .boows-selected .finf { display: none; }
.boows-select .boows-selected .info { color: inherit; }
.boows-select-item.boows-selected { padding: 0; }
.boows-container.boows-floating-label .boows-select .boows-select-item.boows-selected .item-text {
  padding-top: 0.2rem;
  transform: none;
}

/* Multiline: im ausgewählten Zustand .finf ausblenden */
.boows-container.multiline .boows-select .boows-selected .finf {
  display: none;
}

.boows-container.multiline .boows-select .boows-selected .info {
  display: inline;
}

/* Variante: Custom-Label-Select im Headerbereich */
.boows-custom-label-select .boows-select {
  margin-right: 0.25rem;
  background: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.15);
  border-color: var(--boows-col-primary, #dfb843);
}

/* Geöffneter Trigger-Hintergrund */
.boows-select.opened {
  background: #fff;
}

/* =========================================================
   Select-Box Container (Chips für Multi-Select)
   ========================================================= */
.boows-select-box-container {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--boows-space-1, 0.5rem);
  margin-top: var(--boows-space-2, 0.75rem);
}

.boows-select-box-container .boows-select-item {
  display: inline-flex;
  width: auto;
  border-radius: 999px;
  border: 1px solid rgba(var(--boows-col-primary-rgb, 223,184,67), 0.25);
  background: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.1);
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  min-height: auto;
  cursor: pointer;
  line-height: 1.2;
}

.boows-select-box-container .boows-select-item:hover {
  background: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.2);
  border-color: rgba(var(--boows-col-primary-rgb, 223,184,67), 0.4);
}

/* Selected-Chip hat ein Close-Icon statt Check */
.boows-select-box-container .boows-select-item.selected {
  position: relative;
  padding-right: 2.1rem;
  width: max-content;
}
.boows-select-box-container .boows-select-item.selected::after {
  content: 'close';
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Material Icons';
  font-size: 1rem;
  width: 1.4rem;
  height: 1.4rem;
  line-height: 1.4rem;
  text-align: center;
  border-radius: 999px;
  color: var(--boows-col-error, #e53935);
  background: rgba(255, 255, 255, 0.85);
}

/* Im Chip-Text kein zusätzlicher linker Abstand */
.boows-select-box-container .boows-select-item .item-text .custom-select-item :not(mark) {
  margin-left: 0;
}

/* =========================================================
   Mobile Alternative (Popup-basierte Auswahl)
   ========================================================= */
.boows-select-mobile-content {
  display: flex;
  flex-direction: column;
  gap: var(--boows-space-2, 0.75rem);
}

.boows-select-mobile-title {
  margin: 0;
}

.boows-select-mobile-search {
  width: 100%;
}

.boows-select-mobile-search-field {
  width: 100%;
  max-width: none !important;
  margin: 0;
}

.boows-select-mobile-search-field .boows-input-inner-box,
.boows-select-mobile-search-field .boows-input-wrapper {
  width: 100%;
  max-width: none !important;
}
.boows-select-mobile-content .boows-input-field.boows-select-mobile-search-field {
  margin: 0;
  max-width: none !important;
}
.boows-select-mobile-content .boows-input-field.boows-select-mobile-search-field .boows-error-text {
  display: none !important;
}

.boows-select-mobile-options {
  display: flex;
  flex-direction: column;
  gap: var(--boows-space-1, 0.5rem);
}

.boows-select-mobile-option {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: var(--boows-space-2, 0.75rem);
  border-bottom: 1px solid var(--boows-col-text-10, rgba(0,0,0,0.06));
  cursor: pointer;
}

.boows-select-mobile-option input {
  flex: 0 0 auto;
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--boows-col-primary, #08a29a);
}

.boows-select-mobile-option .item-text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.625rem;
  width: 100%;
}

.boows-popup.boows-select-mobile-popup-multiline .boows-select-mobile-option {
  align-items: flex-start;
}

.boows-popup.boows-select-mobile-popup-multiline .boows-select-mobile-option .item-text {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.15rem;
}

.boows-select-mobile-option .boows-select-mobile-flag {
  width: 22px;
  height: 22px;
  object-fit: cover;
  display: inline-block;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
/* Circle only when flag has circle-flag class or parent container has flag-circle */
.boows-select-mobile-option .boows-select-mobile-flag.circle-flag,
.flag-circle .boows-select-mobile-option .boows-select-mobile-flag {
  border-radius: 50%;
}

.boows-select-mobile-option .item-text .finf {
  font-weight: 600;
}

.boows-select-mobile-option .item-text .info {
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.boows-select-mobile-search.boows-input {
  width: 100%;
}

/* =========================================================
   Custom-Label Wrapper
   ========================================================= */
.boows-custom-label-wrapper {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: var(--boows-max-input-width, 26.25rem);
}

.boows-custom-label-wrapper > .boows-container.boows-custom-label-select {
  flex: 0 0 min(10.5rem, 42%);
  max-width: min(10.5rem, 42%);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.boows-custom-label-wrapper > .boows-container.boows-custom-label-select .boows-select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.boows-custom-label-wrapper > .boows-input-inner-box {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
}

.boows-custom-label-wrapper > .boows-input-inner-box .boows-input-wrapper {
  max-width: none;
}

.boows-custom-label-wrapper > .boows-input-inner-box .boows-input-wrapper input,
.boows-custom-label-wrapper > .boows-input-inner-box .boows-input-wrapper select,
.boows-custom-label-wrapper > .boows-input-inner-box .boows-input-wrapper textarea {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.boows-custom-label-wrapper > .boows-container.phone {
  flex: 1 1 auto;
  max-width: none;
  margin-left: -1px;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* =========================================================
   Country Select (native) with flags
   ========================================================= */
.boows-country-select option {
  background-repeat: no-repeat;
  background-position: 4px center;
  padding-left: 28px;
}

.boows-country-select option[data-flag] {
  background-image: none;
  background-size: 5652px 15px;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .boows-country-select option[data-flag] {
    background-image: url("../images/flags/flags@2x.png");
  }
}
