/* ==========================================================================
   5. SELECT2 KÜTÜPHANESİ ÖZELLEŞTİRMELERİ
   ==========================================================================
*/

/* === BAŞLANGIÇ: KURAL YÖNETİMİ SELECT2 STİLLERİ === */

.knsdd-product-select-wrapper,
.knsdd-customer-select-wrapper,
.knsdd-category-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    vertical-align: top; 
}
.knsdd-product-label,
.knsdd-customer-label,
.knsdd-category-label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
}

/* Label + Clear button başlık satırı */
#knsdd-rules-table .knsdd-select-header,
#knsdd-campaign-modal .knsdd-select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Tümünü temizle butonu (ürün & müşteri) - Kural tablosu ve modal */
#knsdd-rules-table .knsdd-clear-selection-btn,
#knsdd-campaign-modal .knsdd-clear-selection-btn {
    margin-left: auto;
    background: #f6f7f7;
    color: #444;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    width: 18px;
    height: 18px;
    line-height: 1;
    font-size: 12px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
#knsdd-rules-table .knsdd-clear-selection-btn:hover:not(.is-disabled):not(:disabled),
#knsdd-rules-table .knsdd-clear-selection-btn:focus-visible:not(.is-disabled):not(:disabled),
#knsdd-campaign-modal .knsdd-clear-selection-btn:hover:not(.is-disabled):not(:disabled),
#knsdd-campaign-modal .knsdd-clear-selection-btn:focus-visible:not(.is-disabled):not(:disabled) {
    background: #f6f7f7; /* açık gri arka plan */
    color: #d63638;  /* WP kırmızısı */
    border-color: #e2e4e7;
}
#knsdd-rules-table .knsdd-clear-selection-btn svg,
#knsdd-campaign-modal .knsdd-clear-selection-btn svg {
    width: 6px !important;
    height: 6px !important;
    display: block;
    stroke-width: 2.75 !important;
}
#knsdd-rules-table .knsdd-clear-selection-btn.is-disabled,
#knsdd-rules-table .knsdd-clear-selection-btn:disabled,
#knsdd-campaign-modal .knsdd-clear-selection-btn.is-disabled,
#knsdd-campaign-modal .knsdd-clear-selection-btn:disabled {
    opacity: .5;
    cursor: default;
}
#knsdd-rules-table .knsdd-clear-selection-btn.is-hidden,
#knsdd-campaign-modal .knsdd-clear-selection-btn.is-hidden { display: none !important; }

/* Yalnızca Kategori alanında Select2 ok ikonunu kaldır */
#knsdd-rules-table .knsdd-category-select-wrapper .select2-selection__arrow {
    display: none !important;
}
#knsdd-rules-table .knsdd-category-select-wrapper .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-right: 8px !important;
}
.knsdd-rules-table .select2-container--default .select2-selection--single,
.knsdd-rules-table .select2-container--default .select2-selection--multiple {
    min-height: 30px !important;
    border: 1px solid #8c8f94 !important;
    border-radius: 3px !important;
}
.knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px !important;
}
#knsdd-rules-table .knsdd-product-select-wrapper .select2-container,
#knsdd-rules-table .knsdd-customer-select-wrapper .select2-container {
    min-width: 300px !important;
}
#knsdd-rules-table .knsdd-product-select-wrapper .select2-search__field,
#knsdd-rules-table .knsdd-customer-select-wrapper .select2-search__field {
    text-align: left !important;
}

/* Çoklu seçim alanları: dış çerçeveyi yuvarlak tut, scroll'u iç render alanına ver */
#knsdd-rules-table .select2-container--default .select2-selection--multiple {
    overflow: hidden !important; /* sağ üst/alt köşe yuvarlaklığını koru */
}
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    max-height: 90px !important; /* sabit yükseklik */
    overflow-y: auto !important; /* iç scroll */
    padding-right: 6px !important; /* scrollbar için küçük iç boşluk */
}

/* Select2 çoklu seçimde arama girişini chip'lerin SOLUNA almak için sıralamayı değiştir */
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
}
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-search--inline {
    order: -1 !important; /* arama alanını başa al */
}
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__choice {
    order: 0 !important; /* chip'ler aramadan sonra gelsin */
}
#knsdd-rules-table .select2-search--inline .select2-search__field {
    min-width: 2ch !important; /* caret görünürlüğü için küçük bir min genişlik */
    text-align: left !important;
}

/* Kategori Select2 için minimum genişlik ve konumlandırma referansı */
#knsdd-rules-table .select2-container--default .select2-selection--single,
#knsdd-campaign-modal .select2-container--default .select2-selection--single {
    min-width: 250px !important;
    position: relative !important; /* clear ikonunu mutlak konumlandırmak için */
    height: 31px !important; /* görsel eşitleme için +1px */
}

/* Modal kategori dropdown ok simgesini gizle */
#knsdd-campaign-modal .select2-container--default .select2-selection--single .select2-selection__arrow,
#knsdd-campaign-modal .select2-container--default .select2-selection--single .select2-selection__arrow b {
    display: none !important;
    visibility: hidden !important;
}

/* Kategori (tek seçim) temizleme ikonunu (x) kırmızı ve belirgin yap */
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__clear,
#knsdd-campaign-modal .select2-container--default .select2-selection--single .select2-selection__clear {
    color: #a00 !important;
    opacity: 0.9 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    line-height: 1 !important;
    position: absolute !important;
    left: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    width: 16px !important;
    text-align: center !important;
}
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__clear:hover,
#knsdd-campaign-modal .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #d00 !important;
    opacity: 1 !important;
}

/* Metnin solunda x ikonu için içeride yer aç */
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__rendered,
#knsdd-campaign-modal .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 24px !important; /* x ile metin arasını aç */
    line-height: 31px !important; /* görsel eşitleme için +1px */
}

/* Ok (dropdown arrow) yüksekliğini de eşitle */
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 31px !important;
}
/* Select2 default siyah üçgeni gizle ve özel ok simgesi ekle */
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border: none !important;
    width: 12px !important; height: 12px !important;
    margin: 0 !important;
    left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2350575e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat !important;
    background-size: 12px 12px !important;
    background-position: center center !important;
}
/* Açıkken vurgu rengi */
#knsdd-rules-table .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232271b1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
}
/* Not: Placeholder hizalaması için eklenen flex ve text-align ezmeleri kaldırıldı */
#knsdd-rules-table .select2-selection__choice {
    position: relative !important;
    padding: 3px 10px 3px 22px !important; /* chip içinde x ile metin arasında boşluk azaltıldı */
}
#knsdd-rules-table .select2-selection__choice__remove,
#knsdd-campaign-modal .select2-selection__choice__remove {
    display: inline-block !important;
    position: absolute !important;
    left: 6px !important; /* compact için biraz içe al */
    top: 50% !important;
    transform: translateY(-50%) !important;
    font-size: 16px !important;
    line-height: 1 !important;
    color: #a00 !important;
    opacity: 0.7 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 20px !important; /* tıklanabilir alanı büyüt */
    height: 20px !important;
    text-align: center !important;
    border: none !important;
}
#knsdd-rules-table .select2-selection__choice__remove:hover,
#knsdd-campaign-modal .select2-selection__choice__remove:hover {
    opacity: 1 !important;
    color: #d00 !important;
}

/* KNSDD ÖZEL MOD: Dropdown içi arama kullanılırken inline (chip içi) arama alanını gizle */
#knsdd-rules-table .knsdd-dropdown-search-mode .select2-search--inline,
#knsdd-campaign-modal .knsdd-dropdown-search-mode .select2-search--inline {
    display: none !important;
}

/* Dropdown arama alanı için hafif iyileştirme (çerçeve/padding) */
.select2-container .select2-dropdown .select2-search.select2-search--dropdown {
    padding: 6px 8px !important;
    border-bottom: 1px solid #e2e4e7 !important;
}
.select2-container .select2-dropdown .select2-search--dropdown .select2-search__field {
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 6px 8px !important;
    border: 1px solid #8c8f94 !important;
    border-radius: 3px !important;
    outline: none !important;
}
.select2-container .select2-dropdown .select2-search--dropdown .select2-search__field:focus {
    border-color: #2271b1 !important;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15) !important;
}

/* === SON: KURAL YÖNETİMİ SELECT2 STİLLERİ === */

/* === BAŞLANGIÇ: KURAL TABLOSU NATIVE SELECT OKLARI (GÖRSEL TUTARLILIK) === */
.knsdd-rules-table select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 28px; /* sağda ok için yer */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2350575e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px 12px;
}
.knsdd-rules-table select:focus {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232271b1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
}
/* === SON: KURAL TABLOSU NATIVE SELECT OKLARI === */


/* ==========================================================================
   8. ÇEŞİTLİ YARDIMCI SINIFLAR
   ==========================================================================
*/
.flatpickr-calendar .flatpickr-quick-select { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #f0f0f1; border-top: 1px solid #ddd; }
.flatpickr-calendar .flatpickr-quick-select-button { background: #2271b1; color: white; border: none; padding: 6px 10px; border-radius: 3px; cursor: pointer; font-size: 12px; transition: background-color 0.2s ease; flex-grow: 1; }
.flatpickr-calendar .flatpickr-quick-select-button:hover { background: #135e96; }


/* ==========================================================================
   5. VENDOR (ÜÇÜNCÜ PARTİ) STİLLERİNİ EZME (OVERRIDE)
   ==========================================================================
*/

/* --------------------------------------------------------------------------
   5.1. Select2 Kütüphanesi için Düzeltmeler
   -------------------------------------------------------------------------- */

/* Devre dışı bırakılmış Select2 kutucuklarının görünümünü iyileştir */
.select2-container--disabled .select2-selection--single,
.select2-container--disabled .select2-selection--multiple {
    background-color: #e9ecef; /* Daha belirgin bir devre dışı rengi */
    cursor: not-allowed;
}

/* *** GÜÇLENDİRİLMİŞ KURAL: Devre dışı Select2'ye tıklanınca çıkan siyah çerçeveyi kaldır *** */
.select2-container--disabled .select2-selection:focus,
.select2-container--disabled .select2-selection--single:focus,
.select2-container--disabled .select2-selection--multiple:focus,
.select2-container--disabled *:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: #8c8f94 !important; /* Kenarlık rengini varsayılan pasif renge sabitler */
}

/* Not: Select2 açıkken label animasyonu için ekstra stil gerekmiyor; boş ruleset kaldırıldı. */

/* Geri Yüklendi: Select2 açıkken seçim metni için önceki boş ruleset (uyumluluk amaçlı) */
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__rendered,
.select2-container--default.select2-container--open .select2-selection--multiple .select2-selection__rendered {
  /* Intentionally left minimal to restore cascade point; prevents bazı temalarda arama kutusu görsel kaymalarını */
  color: inherit;
}

/* === KNSDD: Soft Pills (Compact) – Görsel chip ve sonuç satırı stilleri === */

/* Dropdown sonuç satırı */
.select2-results__option .knsdd-s2-option { display: flex; align-items: center; gap: 8px; }
.select2-results__option .knsdd-s2-thumb { width: 18px; height: 18px; object-fit: cover; border-radius: 3px; flex: 0 0 18px; }
.select2-results__option .knsdd-s2-text { display: flex; flex-direction: column; min-width: 0; }
.select2-results__option .knsdd-s2-title { font-size: 13px; color: #1d2327; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select2-results__option .knsdd-s2-sku { font-size: 11px; color: #646970; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select2-results__option .knsdd-s2-meta { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.select2-results__option .knsdd-s2-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.select2-results__option .knsdd-s2-dot.s-instock { background-color: #24a148; }
.select2-results__option .knsdd-s2-dot.s-onbackorder { background-color: #f1c40f; }
.select2-results__option .knsdd-s2-dot.s-outofstock { background-color: #dc3232; }
.select2-results__option .knsdd-s2-qty { font-size: 11px; color: #50575e; }

/* Seçim çipi (chip) - Kural tablosu ve modal için */
#knsdd-rules-table .knsdd-s2-chip,
#knsdd-campaign-modal .knsdd-s2-chip { display: inline-flex; align-items: center; gap: 6px; }
#knsdd-rules-table .knsdd-s2-chip-thumb,
#knsdd-campaign-modal .knsdd-s2-chip-thumb { width: 16px; height: 16px; object-fit: cover; border-radius: 3px; display: inline-block; }
#knsdd-rules-table .knsdd-s2-chip-text,
#knsdd-campaign-modal .knsdd-s2-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* knsdd-s2-dropdown compact rules removed by request */

/* Chip kapsayıcılarının kompakt pil görünümü – kural tablosu ve modal */
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__choice,
#knsdd-campaign-modal .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #f0f2f4 !important;
    border-color: #d0d5da !important;
    color: #1d2327 !important;
    padding: 2px 10px 2px 24px !important; /* compact */
}
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__choice:hover,
#knsdd-campaign-modal .select2-container--default .select2-selection--multiple .select2-selection__choice:hover {
    background-color: #e7ecf0 !important;
}

/* Compact satır yüksekliği & iç boşluklar */
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__rendered,
#knsdd-campaign-modal .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    gap: 3px 6px !important; /* dikey 3px, yatay 6px */
}
#knsdd-rules-table .select2-container--default .select2-selection--multiple .select2-selection__choice,
#knsdd-campaign-modal .select2-container--default .select2-selection--multiple .select2-selection__choice {
    margin: 3px 6px 3px 0 !important; /* dikey 3px, yatay 6px */
}

/* Çip içi stok meta alanı (nokta+adet) */
#knsdd-rules-table .knsdd-s2-chip-meta,
#knsdd-campaign-modal .knsdd-s2-chip-meta { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; }
#knsdd-rules-table .knsdd-s2-dot,
#knsdd-campaign-modal .knsdd-s2-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
#knsdd-rules-table .knsdd-s2-dot.s-instock,
#knsdd-campaign-modal .knsdd-s2-dot.s-instock { background-color: #24a148; }
#knsdd-rules-table .knsdd-s2-dot.s-onbackorder,
#knsdd-campaign-modal .knsdd-s2-dot.s-onbackorder { background-color: #f1c40f; }
#knsdd-rules-table .knsdd-s2-dot.s-outofstock,
#knsdd-campaign-modal .knsdd-s2-dot.s-outofstock { background-color: #dc3232; }
#knsdd-rules-table .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 13px !important;
}
