/* ==========================================================================
   3. TABLO STİLLERİ
   ==========================================================================
*/

/* --------------------------------------------------------------------------
   3.1. Genel Tablo Yapısı
   -------------------------------------------------------------------------- */
.knsdd-standard-discount-config,
.knsdd-special-campaign-config {
    display: flex;
    align-items: center;
    gap: 5px;
}

#knsdd-rules-table .knsdd-info-tooltip-large svg {
    width: 20px !important;
    height: 20px !important;
}

/* --------------------------------------------------------------------------
   3.2. Kural Yönetim Tablosu (#knsdd-rules-table)
   -------------------------------------------------------------------------- */
#knsdd-rules-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #c3c4c7;
}

#knsdd-rules-table th,
#knsdd-rules-table td {
    padding: 8px 10px;
    vertical-align: middle;
    white-space: nowrap;
}

#knsdd-rules-table td {
    padding-top: 12px;
    padding-bottom: 12px;
}

#knsdd-rules-table input[type="number"] {
    width: 70px;
    text-align: center;
    height: 30px;
}

.knsdd-actions-column {
    text-align: center !important;
}

.knsdd-login-required-cell {
    text-align: center;
}

/* Kategori sütunu (artık 2. sütun) içeriğini zorla sola hizala */
#knsdd-rules-table td:nth-child(2) {
    text-align: left !important;
}

#knsdd-rules-table td:nth-child(2) .select2-container {
    text-align: left !important;
}

.knsdd-actions-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 30px;
}

/* Kampanya Türü Badge - Daha Belirgin Tasarım */
.knsdd-rule-type-display {
    margin-bottom: 8px;
}

.knsdd-rule-type-badge {
    display: inline-block;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    text-align: center;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Miktar İndirimi - Teal */
.knsdd-badge-standard_discount {
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    color: #fff;
    border: none;
    box-shadow: 0 2px 4px rgba(26, 188, 156, 0.3);
}

/* Özel Kampanya - Mor */
.knsdd-badge-special_campaign {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: #fff;
    border: none;
    box-shadow: 0 2px 4px rgba(155, 89, 182, 0.3);
}

/* Satırlara sol kenar şeridi */
#knsdd-rules-table tr[data-rule-type="standard_discount"] td:first-child {
    border-left: 4px solid #1abc9c;
}

#knsdd-rules-table tr[data-rule-type="special_campaign"] td:first-child {
    border-left: 4px solid #9b59b6;
}


/* Yapılandırılmamış kurallarda nabız animasyonu */
@keyframes pulse-attention {
    0% {
        box-shadow: 0 0 0 0 rgba(155, 89, 182, 0.5);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(155, 89, 182, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(155, 89, 182, 0);
    }
}

tr[data-rule-type="special_campaign"] .knsdd-configure-campaign-btn:not(.configured) {
    animation: pulse-attention 2s infinite;
}

/* Alan Genişlikleri (yeni sütun sırası) */
/* Kampanya Türü (1. sütun) */
#knsdd-rules-table th:nth-child(1),
#knsdd-rules-table td:nth-child(1) {
    width: 15%;
    min-width: 160px;
}

/* Geçerli Müşteriler (artık 7. sütun) */
#knsdd-rules-table th:nth-child(7),
#knsdd-rules-table td:nth-child(7) {
    width: 25%;
    min-width: 250px;
    white-space: normal;
}

/* Kopya kuralların görsel olarak vurgulanması */
#knsdd-rules-table tr.knsdd-row-duplicate {
    border-left: 1px solid #dc3232 !important;
    border-right: 1px solid #dc3232 !important;
    background-color: rgba(220, 50, 50, 0.06);
}

#knsdd-rules-table tr.knsdd-row-duplicate-start {
    border-top: 1px solid #dc3232 !important;
}

#knsdd-rules-table tr.knsdd-row-duplicate-end {
    border-bottom: 1px solid #dc3232 !important;
}

/* Süresi bitmiş kampanyalarda kural satırları (Read-only görsel feedback) */
#knsdd-rules-table tr.knsdd-expired-row {
    opacity: 0.65;
    background-color: #f5f5f5;
}

#knsdd-rules-table tr.knsdd-expired-row select,
#knsdd-rules-table tr.knsdd-expired-row input {
    background-color: #fafafa !important;
    cursor: not-allowed !important;
}

#knsdd-rules-table tr.knsdd-expired-row button.knsdd-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Limitler butonu: Tıklanabilir, görüntüleme modu - sürekli camgöbeği (hover rengi) */
#knsdd-rules-table tr.knsdd-expired-row button.knsdd-btn-readonly {
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    color: #17a2b8 !important;
    background-color: rgba(23, 162, 184, 0.1) !important;
}

/* === Kural satırlarında label olmayan sütunlar için üstte küçük label ekle (metinli çözüm) === */
.knsdd-inline-label-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.knsdd-inline-label {
    font-size: 12px;
    font-weight: 600;
    color: #444;
}

/* Müşteri Koşulları kolonunda label/checkbox yan yana iken optik hizalama (artık 6. sütun) */
#knsdd-rules-table td:nth-child(6) .knsdd-inline-label {
    margin-top: 0;
}

/* Sadece Üyeler hücresinde checkbox'ı yatayda ortala */
#knsdd-rules-table td.knsdd-login-required-cell {
    white-space: normal;
    text-align: left !important;
}

#knsdd-rules-table td.knsdd-login-required-cell .knsdd-inline-label-wrapper {
    display: grid;
    grid-template-columns: auto auto;
    /* metin | checkbox (yan yana, yakın hizalama) */
    justify-content: start;
    /* sol hizalama, boşluk bırakma */
    justify-items: start;
    /* grid içi öğeleri sola sabitle */
    align-items: center;
    column-gap: 8px;
    /* metin ile checkbox arası */
    row-gap: 6px;
    /* satırlar arası boşluk */
}

/* Metinlerin sol kenara boşluksuz oturması için ekstra güvenlik */
#knsdd-rules-table td.knsdd-login-required-cell .knsdd-inline-label-wrapper {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

#knsdd-rules-table td.knsdd-login-required-cell .knsdd-inline-label {
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* Min/Max kolonlarındaki label'ları başlıkla bire bir sol hizala (artık 4. ve 5. sütun) */
#knsdd-rules-table td:nth-child(4),
#knsdd-rules-table td:nth-child(5) {
    text-align: left !important;
}

#knsdd-rules-table td:nth-child(4) .knsdd-inline-label-wrapper,
#knsdd-rules-table td:nth-child(5) .knsdd-inline-label-wrapper {
    padding-left: 0 !important;
    margin-left: 0 !important;
    align-items: flex-start;
}

#knsdd-rules-table td:nth-child(4) .knsdd-inline-label,
#knsdd-rules-table td:nth-child(5) .knsdd-inline-label {
    display: block;
    padding-left: 0 !important;
    margin-left: 0 !important;
}

/* İşlemler kolonu için boş label görünümüyle hizalama */
#knsdd-rules-table td:nth-child(8) {
    padding-top: 0;
}

#knsdd-rules-table td:nth-child(8)::before {
    content: '';
    display: block;
    height: 18px;
    /* diğer label yüksekliğiyle benzer */
}

/* Min/Max devre dışı görsel ipucu */
#knsdd-rules-table input.knsdd-rule-min[disabled],
#knsdd-rules-table input.knsdd-rule-max[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   3.3. Grup Yönetim Tablosu (#knsdd-toggle-table)
   -------------------------------------------------------------------------- */
#knsdd-toggle-table {
    table-layout: fixed;
    width: 100%;
    border-radius: 3px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #c3c4c7;
}

/* Grup Tablosu - Kampanya Tipi Renk Kodlaması */
#knsdd-toggle-table tr[data-rule-type="fixed_discount"] td:first-child {
    border-left: 4px solid #1abc9c;
}

#knsdd-toggle-table tr[data-rule-type="special_campaign"] td:first-child {
    border-left: 4px solid #9b59b6;
}

#knsdd-toggle-table th,
#knsdd-toggle-table td {
    text-align: left;
    vertical-align: middle;
}

#knsdd-toggle-table th:nth-child(4),
#knsdd-toggle-table th:nth-child(5),
#knsdd-toggle-table th:nth-child(6) {
    text-align: center;
}

#knsdd-toggle-table .knsdd-date-input {
    width: 100%;
    box-sizing: border-box;
}

/* Kolon genişlikleri (6 kolon - checkbox Grup Adı ile birleşik) */
#knsdd-toggle-table th:nth-child(1) {
    width: 35%;
}

/* Grup Adı (checkbox dahil) */
#knsdd-toggle-table th:nth-child(2) {
    width: 12%;
}

/* Başlangıç */
#knsdd-toggle-table th:nth-child(3) {
    width: 12%;
}

/* Bitiş */
#knsdd-toggle-table th:nth-child(4) {
    width: 10%;
}

/* Durum */
#knsdd-toggle-table th:nth-child(5) {
    width: 16%;
}

/* Durum Bilgisi */
#knsdd-toggle-table th:nth-child(6) {
    width: 15%;
}

/* İşlemler */

/* Gruplar tablosundaki işlem ikonlarını kurallar tablosuyla eşle (boyut/hizalama) */
#knsdd-toggle-table .knsdd-actions-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 30px;
}

#knsdd-toggle-table .knsdd-action-btn {
    width: 28px;
    height: 28px;
    padding: 0;
}

/* Tablo hizalamaları: sabit sütun genişlikleri ile kaymaları önle */
.wp-list-table #knsdd-toggle-table th:nth-child(2),
.wp-list-table #knsdd-toggle-table td:nth-child(2) {
    width: 180px;
}

.wp-list-table #knsdd-toggle-table th:nth-child(3),
.wp-list-table #knsdd-toggle-table td:nth-child(3) {
    width: 180px;
}

.wp-list-table #knsdd-toggle-table th:nth-child(4),
.wp-list-table #knsdd-toggle-table td:nth-child(4) {
    width: 110px;
    text-align: center;
}

.wp-list-table #knsdd-toggle-table th:nth-child(5),
.wp-list-table #knsdd-toggle-table td:nth-child(5) {
    width: 180px;
    text-align: center;
}

.wp-list-table #knsdd-toggle-table th:nth-child(6),
.wp-list-table #knsdd-toggle-table td:nth-child(6) {
    width: 120px;
}

/* Inputların taşmasını önle */
#knsdd-toggle-table input.knsdd-date-input {
    width: 100%;
    box-sizing: border-box;
}

#knsdd-toggle-table .knsdd-status-badge {
    display: block;
    width: 120px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* Switch hücresini dikey ve yatay ortala */
#knsdd-toggle-table td:nth-child(4) {
    vertical-align: middle;
    text-align: center;
    /* switch'i yatayda ortala */
}

#knsdd-toggle-table td:nth-child(4) .knsdd-toggle-switch {
    display: inline-block;
}

#knsdd-toggle-table td:nth-child(4) .knsdd-toggle-slider {
    margin: 0 auto;
}

/* Durum Bilgisi hücresini dikey ve yatay ortala */
.wp-list-table #knsdd-toggle-table td:nth-child(5) {
    vertical-align: middle;
    text-align: center;
}

/* Kopya tarih+aynı kural seti çakışmalarında satırı görsel olarak vurgula
   Not: WP admin tablolarında <tr> border'ı çoğu zaman görünmez; bu yüzden <td>'lere uygula. */
#knsdd-toggle-table tr.knsdd-row-conflict>td {
    background-color: rgba(220, 50, 50, 0.12) !important;
}

#knsdd-toggle-table tr.knsdd-row-conflict>td:first-child {
    border-left: 1px solid #dc3232 !important;
}

#knsdd-toggle-table tr.knsdd-row-conflict>td:last-child {
    border-right: 1px solid #dc3232 !important;
}

#knsdd-toggle-table tr.knsdd-row-conflict-start>td {
    border-top: 1px solid #dc3232 !important;
}

#knsdd-toggle-table tr.knsdd-row-conflict-end>td {
    border-bottom: 1px solid #dc3232 !important;
}

/* Satır altı inline hata satırı (soft rose ton, minimal alan) */
#knsdd-toggle-table tr.knsdd-inline-error-row>td {
    background-color: #fde8e8 !important;
    /* soft rose arka plan */
    border: 1px solid #f5b5b5 !important;
    /* soft rose kenarlık */
    color: #7a1f1f;
    /* metin */
    padding: 6px 10px;
    font-weight: 600;
    font-size: 12.5px;
    line-height: 1.3;
}
