/* ==========================================================================
   MotoPiyasa — Select2 birleşik stil (Bootstrap 5 teması üzerine)
   Tek kaynak: tüm select2 kullanılan sayfalarda bu dosya yüklenir.
   Hedef: select2 kutusu diğer form inputlarıyla birebir aynı görünsün.
   Standart: yükseklik 42px · radius 8px · font 14px · kenar #ced4da
   ========================================================================== */

:root {
  --mp-s2-height: 42px;
  --mp-s2-radius: 8px;
  --mp-s2-border: #ced4da;
  --mp-s2-border-focus: var(--mp-primary, #da2128);
  --mp-s2-font: 14px;
  --mp-s2-text: #333;
  --mp-s2-placeholder: #8a9099;
}

/* --- Container: her zaman blok ve tam genişlik ------------------------- */
.select2-container {
  width: 100% !important;
  max-width: 100%;
  display: block;
}
.select2-container .select2-selection {
  box-sizing: border-box;
}

/* --- Tekli seçim kutusu = .form-select görünümü ------------------------ */
.select2-container--bootstrap-5 .select2-selection--single,
.select2-container--default .select2-selection--single {
  display: flex;
  align-items: center;
  min-height: var(--mp-s2-height);
  height: var(--mp-s2-height);
  padding: 0 0.6rem 0 0.75rem;
  border: 1px solid var(--mp-s2-border);
  border-radius: var(--mp-s2-radius);
  background-color: #fff;
  font-size: var(--mp-s2-font);
  line-height: 1.4;
  color: var(--mp-s2-text);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  margin: 0;
  line-height: 1.4;
  color: var(--mp-s2-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder,
.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--mp-s2-placeholder);
}

/* Ok simgesi — akış içi flex öğesi (en sağda) */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
  order: 3;
  position: static;
  flex: 0 0 auto;
  width: 20px;
  height: auto;
  margin-left: 2px;
  transform: none;
}

/* --- Odak durumu: marka rengi + yumuşak halka ------------------------- */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection,
.select2-container--default.select2-container--focus .select2-selection,
.select2-container--default.select2-container--open .select2-selection {
  border-color: var(--mp-s2-border-focus);
  box-shadow: 0 0 0 0.2rem rgba(218, 33, 40, 0.15);
  outline: 0;
}

/* --- Devre dışı ------------------------------------------------------- */
.select2-container--bootstrap-5.select2-container--disabled .select2-selection,
.select2-container--default.select2-container--disabled .select2-selection {
  background-color: #e9ecef;
  color: #6c757d;
  cursor: not-allowed;
}

/* --- Temizle (×) düğmesi — sağda, ok simgesinin solunda, ince gri ------ */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear,
.select2-container--default .select2-selection--single .select2-selection__clear {
  order: 2;
  position: static;
  float: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0 4px;
  padding: 5px;
  border: 0;
  border-radius: 50%;
  background: #eee;
  color: red;
  font-size: 15px;
  text-indent: 0;
  font-weight: 700;
  line-height: 1;
  opacity: 1;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
  top:0;
  transform: none;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear span,
.select2-container--default .select2-selection--single .select2-selection__clear span {
  display: none !important; /* kendi × işaretimizi kullan */
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear::before,
.select2-container--default .select2-selection--single .select2-selection__clear::before {
  content: "\00d7";
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover,
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__clear:hover, 
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear:hover {
  background: #da2128;
  color: #fff !important;
}

/* --- Çoklu seçim (chip) kutusu ---------------------------------------- */
.select2-container--bootstrap-5 .select2-selection--multiple {
  min-height: var(--mp-s2-height);
  padding: 3px 6px;
  border: 1px solid var(--mp-s2-border);
  border-radius: var(--mp-s2-radius);
  background-color: #fff;
  font-size: var(--mp-s2-font);
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__rendered {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0;
  margin: 0;
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
  display: inline-flex;
  align-items: center;
  margin: 2px 0 0 0;
  padding: 2px 8px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #f3f4f6;
  color: #333;
  font-size: 12px;
  line-height: 1.4;
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
  order: 2;
  margin-left: 6px;
  margin-right: 0;
  color: #b51a20;
  border: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1;
}
.select2-container--bootstrap-5 .select2-selection--multiple .select2-search--inline .select2-search__field {
  margin-top: 0;
  height: 26px;
  font-size: var(--mp-s2-font);
}

/* --- Açılır liste (dropdown) ------------------------------------------ */
.select2-container--bootstrap-5 .select2-dropdown,
.select2-container--default .select2-dropdown {
  border: 1px solid var(--mp-s2-border);
  border-radius: var(--mp-s2-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 10060 !important;
}
.select2-container--open {
  z-index: 10060 !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown,
.select2-container--default .select2-search--dropdown {
  padding: 8px;
}
.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field,
.select2-container--default .select2-search--dropdown .select2-search__field {
  height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--mp-s2-border);
  border-radius: 6px;
  font-size: var(--mp-s2-font);
  outline: 0;
}
.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus,
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  border-color: var(--mp-s2-border-focus);
  box-shadow: 0 0 0 0.15rem rgba(218, 33, 40, 0.15);
}

.select2-container--bootstrap-5 .select2-results__options,
.select2-container--default .select2-results__options {
  max-height: 260px;
}
.select2-container--bootstrap-5 .select2-results__option,
.select2-container--default .select2-results__option {
  padding: 8px 12px;
  font-size: var(--mp-s2-font);
  color: #333;
}
.select2-container--bootstrap-5 .select2-results__option--highlighted,
.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--mp-primary, #da2128);
  color: #fff;
}
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: #fbe9ea;
  color: #333;
}

/* --- Yükleme öncesi CLS (kayma) engelle --------------------------------
   Native select select2'ye dönüşürken yükseklik farkı sayfayı kaydırmasın.
   İçinde js olan formda ham select'i select2 ölçüsünde tut. */
select.mp-ilan-s2:not(.select2-hidden-accessible),
select.mp-wiki-select:not([multiple]):not(.select2-hidden-accessible),
select.mp-wiki-model-select:not([multiple]):not(.select2-hidden-accessible),
select.mp-moto-renk-select:not(.select2-hidden-accessible),
select.mp-moto-uye-select:not(.select2-hidden-accessible),
select.mp-moto-servis-select:not(.select2-hidden-accessible),
select.mp-moto-islem-select:not(.select2-hidden-accessible),
select.uyeler_ajax:not(.select2-hidden-accessible),
select.ilsec:not(.select2-hidden-accessible),
select.ilcesec:not(.select2-hidden-accessible) {
  min-height: var(--mp-s2-height);
  height: var(--mp-s2-height);
  border-radius: var(--mp-s2-radius);
  border: 1px solid var(--mp-s2-border);
  font-size: var(--mp-s2-font);
}

/* ==========================================================================
   Form içi input/select uyumu — select2'nin bulunduğu form sarmalayıcıları
   içindeki tüm alanlar aynı ölçüde olsun (görsel tutarlılık).
   ========================================================================== */
.mp-ilan-ver-form .form-control:not(textarea),
.mp-ilan-ver-form .form-select,
.mp-account-form .form-control:not(textarea),
.mp-account-form .form-select,
.mp-moto-account-form .form-control:not(textarea),
.mp-moto-account-form .form-select {
  min-height: var(--mp-s2-height);
  height: var(--mp-s2-height);
  border-radius: var(--mp-s2-radius);
  font-size: var(--mp-s2-font);
}
.mp-ilan-ver-form textarea.form-control,
.mp-account-form textarea.form-control,
.mp-moto-account-form textarea.form-control {
  border-radius: var(--mp-s2-radius);
  font-size: var(--mp-s2-font);
}
