/* ==========================================================================
   BM DataTables Override — kart-tarzı satır + kompakt + project primary tema
   (datatable-design.md §5'ten uyarlandı; primary mavi)
   ========================================================================== */

/* ---------- Wrapper ---------- */
.dataTables_wrapper,
.dt-container {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* Excel-tarzı resize: tablo büyürse wrap içinde yatay scroll çıksın */
.bm-table-wrap { overflow-x: auto; max-width: 100%; }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate,
.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-info,
.dt-container .dt-paging {
    font-family: inherit;
    color: #495057;
    padding: .4rem 0;
}

/* ---------- Length selector + Search input ---------- */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-info { font-size: .78rem; }

.dataTables_wrapper .dataTables_length select,
.dt-container .dt-length select {
    padding: .15rem .4rem;
    font-size: .78rem;
    line-height: 1.2;
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    background-color: #fff;
    min-width: 56px;
    margin: 0 .3rem;
}
.dataTables_wrapper .dataTables_filter input,
.dt-container .dt-search input {
    padding: .2rem .5rem;
    font-size: .78rem;
    line-height: 1.2;
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    margin-left: .4rem;
    min-width: 160px;
}
.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus,
.dt-container .dt-length select:focus,
.dt-container .dt-search input:focus {
    outline: 0;
    border-color: var(--custom-bs-primary, #b4231e);
    box-shadow: 0 0 0 .15rem rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .18);
}

/* ---------- Table shell — kart-tarzı satır ---------- */
table.dataTable {
    border-collapse: separate !important;
    border-spacing: 0 2px !important;
    width: 100%;
    margin: .15rem 0 !important;
    border: 0;
    background: transparent;
}

/* Header — shadcn primary tinted, kompakt + ellipsis */
table.dataTable thead th,
table.dataTable thead td {
    background: linear-gradient(180deg,
        rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.08),
        rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.04));
    color: var(--custom-bs-primary, #b4231e);
    font-weight: 600;
    font-size: .75rem;
    padding: .45rem .65rem !important;
    border-bottom: 1px solid rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.18);
    text-align: left !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* DataTables 2.x TH iç wrapper'ı */
table.dataTable thead th .dt-column-header,
table.dataTable thead td .dt-column-header {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
}
table.dataTable thead th .dt-column-title,
table.dataTable thead td .dt-column-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    vertical-align: middle;
}
table.dataTable thead th .dt-column-order,
table.dataTable thead td .dt-column-order { flex: 0 0 auto; }

/* DT 2.x'in last-column-right-align davranışını ez */
table.dataTable thead th.bm-actions-col,
table.dataTable thead th.text-end,
table.dataTable thead th.text-right,
table.dataTable thead th.text-center,
table.dataTable thead th.text-start,
table.dataTable thead th[class*="dt-"] { text-align: left !important; }

table.dataTable thead tr th:first-child { border-top-left-radius: var(--radius); border-bottom-left-radius: 0; }
table.dataTable thead tr th:last-child { border-top-right-radius: var(--radius); border-bottom-right-radius: 0; }

/* Bootstrap `.table-light` / `.table-primary` thead override */
table.dataTable thead.table-light th,
table.dataTable thead.table-primary th,
table.dataTable .table-light > *,
table.dataTable .table-primary > * {
    background: linear-gradient(180deg,
        rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.08),
        rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.04)) !important;
    color: var(--custom-bs-primary, #b4231e) !important;
    border-bottom: 1px solid rgba(var(--custom-bs-primary-rgb, 180, 35, 30), 0.18) !important;
}

/* Body satırları — her biri ayrı kart */
table.dataTable tbody tr {
    background: #fff;
    transition: background-color .12s, box-shadow .12s;
    text-align: left !important;
}

/* Tüm tbody hücreleri sola yaslı — utility class / DT 2.x class override'ları dahil */
table.dataTable tbody tr td,
table.dataTable tbody tr th,
table.dataTable tbody tr.text-center,
table.dataTable tbody tr.text-end,
table.dataTable tbody tr.text-right,
table.dataTable tbody tr.text-start,
table.dataTable tbody tr td.text-center,
table.dataTable tbody tr td.text-end,
table.dataTable tbody tr td.text-right,
table.dataTable tbody tr td.text-start,
table.dataTable tbody tr td.dt-center,
table.dataTable tbody tr td.dt-right,
table.dataTable tbody tr td.dt-left,
table.dataTable tbody tr td[class*="dt-"],
table.dataTable tbody tr th.text-center,
table.dataTable tbody tr th.text-end,
table.dataTable tbody tr th.text-right,
table.dataTable tbody tr th.text-start,
table.dataTable tbody tr th[class*="dt-"] {
    text-align: left !important;
}

/* table-bordered için mavi/gri dikey thead çizgisini kaldır (kart-tarzı satırla uyumsuz) */
table.dataTable.table-bordered,
table.dataTable.table-bordered > :not(caption) > * > * {
    border-color: transparent !important;
    border-left: 0 !important;
    border-right: 0 !important;
}
table.dataTable tbody td,
table.dataTable tbody th {
    padding: .25rem .55rem !important;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.25;
    vertical-align: middle;
    border: 0 !important;
    border-top: 1px solid rgba(0, 0, 0, .06) !important;
    border-bottom: 1px solid rgba(0, 0, 0, .06) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: inherit;
    color: inherit !important;
}

/* `<th scope="row">` (örn. # kolonu) tipik olarak dar olur ve thead stiline kaymasın */
table.dataTable tbody th[scope="row"] {
    width: 48px;
    text-align: left !important;
    color: var(--custom-bs-muted, #6b7280) !important;
    font-weight: 500;
}

/* Action/button/dropdown/form içeren hücreler — clip etme */
table.dataTable tbody td.bm-actions-col,
table.dataTable tbody td:has(.dropdown),
table.dataTable tbody td:has(.btn-group),
table.dataTable tbody td:has(button),
table.dataTable tbody td:has(.badge),
table.dataTable tbody td:has(input),
table.dataTable tbody td:has(select),
table.dataTable tbody td:has(a.btn) {
    overflow: visible;
    white-space: normal;
}

/* Opt-out: kolon zorla wrap yapsın */
table.dataTable tbody td.bm-cell-wrap {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
}

/* İlk/son hücreler — kart yuvarlatma (th[scope=row] de dahil) */
table.dataTable tbody tr > :first-child {
    border-left: 1px solid rgba(0, 0, 0, .06) !important;
    border-top-left-radius: var(--radius);
    border-bottom-left-radius: var(--radius);
}
table.dataTable tbody tr > :last-child {
    border-right: 1px solid rgba(0, 0, 0, .06) !important;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* Tablo wrapper'ı altındaki Bootstrap kalın çizgilerini kaldır.
   `.table > tbody` Bootstrap 5'te 2px alt border alır — kart-tarzı satırla çakışır. */
.table > :not(caption) > * > * {
    border-bottom-width: 0;
}
.table > tbody,
.table > thead,
.table > tfoot,
table.dataTable > tbody,
table.dataTable > thead,
table.dataTable > tfoot {
    border-top: 0 !important;
    border-bottom: 0 !important;
}
.table-responsive,
.dataTables_wrapper,
.dt-container {
    border-bottom: 0 !important;
}

/* Hover, stripe, selected, pasif satır */
table.dataTable tbody tr:hover {
    background-color: #fafbfc !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd,
table.dataTable.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: #fcfcfd !important;
}
table.dataTable.stripe tbody tr.odd:hover,
table.dataTable.display tbody tr.odd:hover,
table.dataTable.table-striped > tbody > tr:nth-of-type(odd):hover {
    background-color: #f6f7f9 !important;
}
table.dataTable tbody tr.selected,
table.dataTable tbody tr.selected:hover {
    background-color: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .08) !important;
    color: inherit !important;
}
table.dataTable tbody tr[data-isactive="0"] {
    background: #fff5f5 !important;
    opacity: .92;
}
table.dataTable tbody tr[data-isactive="0"]:hover {
    background: #ffeef0 !important;
    opacity: 1;
}

/* ---------- Column resize handle ---------- */
.bm-col-resize-handle {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 14px;
    cursor: col-resize;
    z-index: 50;
    user-select: none;
    background: transparent;
    pointer-events: auto;
    transition: background-color .15s;
}
.bm-col-resize-handle::after {
    content: "";
    position: absolute;
    top: 15%; bottom: 15%;
    right: 4px;
    width: 3px;
    border-radius: 2px;
    background: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .35);
    transition: background-color .15s, width .15s;
    pointer-events: none;
}
.bm-col-resize-handle:hover::after,
body.bm-col-resizing .bm-col-resize-handle::after {
    background: var(--custom-bs-primary, #b4231e);
    width: 4px;
}
.bm-col-resize-handle:hover {
    background: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .06);
}
body.bm-col-resizing { cursor: col-resize !important; user-select: none !important; }
body.bm-col-resizing table.dataTable,
body.bm-col-resizing table.dataTable * {
    user-select: none !important;
    cursor: col-resize !important;
}

/* ---------- Sort ---------- */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc,
table.dataTable thead th.dt-orderable-asc,
table.dataTable thead th.dt-orderable-desc { cursor: pointer; }
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc,
table.dataTable thead th.dt-ordering-asc,
table.dataTable thead th.dt-ordering-desc { color: var(--custom-bs-primary, #b4231e); }

/* ---------- Pagination ---------- */
/* ---------- Pagination — global Bootstrap + DataTables 1.x/2.x ---------- */

/* Non-active state */
.pagination .page-link,
.page-link,
.dataTables_wrapper .paginate_button,
.dt-container .dt-paging .page-link,
.dt-container .dt-paging .pagination .page-link,
.dt-container .dt-paging .dt-paging-button .page-link,
div.dt-container div.dt-paging button.dt-paging-button {
    padding: .25rem .6rem !important;
    margin: 0 1px !important;
    border-radius: var(--radius) !important;
    border: 1px solid transparent !important;
    font-size: .78rem;
    color: var(--custom-bs-body-color, #1f2937) !important;
    background-color: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
}

/* Hover */
.pagination .page-link:hover,
.page-link:hover,
.dataTables_wrapper .paginate_button:hover,
.dt-container .dt-paging .page-link:hover,
.dt-container .dt-paging .dt-paging-button:hover .page-link,
div.dt-container div.dt-paging button.dt-paging-button:hover {
    background-color: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .08) !important;
    color: var(--custom-bs-primary, #b4231e) !important;
    border-color: transparent !important;
}

/* Active / current */
.pagination .page-item.active .page-link,
.page-item.active .page-link,
.dataTables_wrapper .paginate_button.current,
.dataTables_wrapper .paginate_button.current:hover,
.dt-container .dt-paging .page-item.active .page-link,
.dt-container .dt-paging .dt-paging-button.active .page-link,
.dt-container .dt-paging .dt-paging-button.current .page-link,
div.dt-container div.dt-paging button.dt-paging-button.current,
div.dt-container div.dt-paging button.dt-paging-button.active {
    background-color: var(--custom-bs-primary, #b4231e) !important;
    border-color: var(--custom-bs-primary, #b4231e) !important;
    color: #fff !important;
    font-weight: 600;
}

/* Disabled */
.pagination .page-item.disabled .page-link,
.page-item.disabled .page-link,
.dataTables_wrapper .paginate_button.disabled,
.dataTables_wrapper .paginate_button.disabled:hover,
.dt-container .dt-paging .page-item.disabled .page-link,
.dt-container .dt-paging .dt-paging-button.disabled .page-link,
div.dt-container div.dt-paging button.dt-paging-button.disabled,
div.dt-container div.dt-paging button.dt-paging-button:disabled {
    color: var(--custom-bs-muted, #9ca3af) !important;
    background-color: transparent !important;
    border-color: transparent !important;
    cursor: not-allowed;
    opacity: 0.55;
}

/* Focus — shadcn ring */
.pagination .page-link:focus,
.page-link:focus,
.dt-container .dt-paging .page-link:focus,
div.dt-container div.dt-paging button.dt-paging-button:focus {
    outline: 2px solid var(--ring) !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

/* ---------- Buttons extension ---------- */
.dt-buttons { margin-right: .5rem; display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.dt-buttons .dt-button,
.dt-buttons .dt-button.buttons-csv,
.dt-buttons .dt-button.buttons-excel,
.dt-buttons .dt-button.buttons-pdf,
.dt-buttons .dt-button.buttons-copy,
.dt-buttons .dt-button.buttons-print,
.dt-buttons .dt-button.buttons-collection {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: .3rem .65rem !important;
    font-family: inherit !important;
    font-size: .78rem !important;
    line-height: 1.25 !important;
    color: var(--custom-bs-primary, #b4231e) !important;
    background: #fff !important;
    border: 1px solid rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .35) !important;
    border-radius: var(--radius) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    margin: 0 !important;
    transition: background-color .15s, border-color .15s, color .15s;
}
.dt-buttons .dt-button:hover,
.dt-buttons .dt-button:focus,
.dt-buttons .dt-button:active,
.dt-buttons .dt-button.active {
    background: var(--custom-bs-primary, #b4231e) !important;
    border-color: var(--custom-bs-primary, #b4231e) !important;
    color: #fff !important;
}
.dt-buttons .dt-button.disabled,
.dt-buttons .dt-button:disabled { opacity: .55; cursor: not-allowed; }

.dt-button-collection {
    padding: .3rem !important;
    border: 1px solid #e9ecef !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08) !important;
    background: #fff !important;
}
.dt-button-collection .dt-button {
    width: 100%;
    justify-content: flex-start;
    border: 0 !important;
    background: transparent !important;
    color: #212529 !important;
    padding: .35rem .55rem !important;
    border-radius: var(--radius) !important;
}
.dt-button-collection .dt-button:hover,
.dt-button-collection .dt-button.active {
    background: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .08) !important;
    color: var(--custom-bs-primary, #b4231e) !important;
}

/* ---------- Processing — ince üst progress bar ---------- */
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dt-processing,
.dt-container .dt-processing,
div.dt-processing {
    top: 0 !important; right: 0 !important; bottom: auto !important; left: auto !important;
    width: 100% !important; height: 3px !important;
    margin: 0 !important; padding: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    background: rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .08) !important;
    box-shadow: none !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    pointer-events: none !important;
}
.dataTables_wrapper .dataTables_processing::before,
.dataTables_wrapper .dt-processing::before,
.dt-container .dt-processing::before,
div.dt-processing::before {
    content: "";
    position: absolute; inset: 0 auto 0 0;
    width: 38%; min-width: 120px;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--custom-bs-primary, #b4231e), transparent);
    animation: bm-dt-loader-bar 1.05s ease-in-out infinite;
}
.dataTables_wrapper .dataTables_processing > div,
.dataTables_wrapper .dt-processing > div,
.dt-container .dt-processing > div,
div.dt-processing > div { display: none !important; }
@keyframes bm-dt-loader-bar {
    from { transform: translateX(-110%); }
    to   { transform: translateX(280%); }
}

/* ---------- bm-server-paging loading overlay ---------- */
.bm-paging-loading-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 18;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    border-radius: var(--radius);
    pointer-events: auto;
    opacity: 0;
    transition: opacity .15s ease-out;
}
.bm-paging-loading-overlay.is-visible { display: flex; opacity: 1; }
.bm-paging-loading-card {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .45rem .9rem;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
    font-size: .8rem;
    color: #495057;
    line-height: 1;
}
.bm-paging-loading-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(var(--custom-bs-primary-rgb, 180, 35, 30), .2);
    border-top-color: var(--custom-bs-primary, #b4231e);
    border-radius: 50%;
    animation: bm-paging-spin .7s linear infinite;
    flex-shrink: 0;
}
.bm-paging-loading-text { font-weight: 500; white-space: nowrap; }
@keyframes bm-paging-spin { to { transform: rotate(360deg); } }

/* ---------- DataTables 2.x scroll wrappers — boyutla ---------- */
.dataTables_wrapper .dt-scroll,
.dataTables_wrapper .dt-scroll-body,
.dataTables_wrapper .dataTables_scroll,
.dataTables_wrapper .dataTables_scrollBody,
.dt-container .dt-scroll,
.dt-container .dt-scroll-body {
    max-width: 100%;
}

/* DT 2.x scroll-head & scroll-body içindeki tablo başlığı/body kart tarzına uyum sağlasın */
.dt-scroll-head table.dataTable,
.dt-scroll-body table.dataTable {
    border-spacing: 0 2px !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 575.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate,
    .dt-container .dt-length,
    .dt-container .dt-search,
    .dt-container .dt-info,
    .dt-container .dt-paging {
        text-align: left;
        float: none !important;
        margin-bottom: .35rem;
    }
    .dataTables_wrapper .dataTables_filter input,
    .dt-container .dt-search input {
        min-width: 0;
        width: 100%;
        margin-left: 0;
        margin-top: .2rem;
    }
}
