/**
 * Shared DataTables theme — matches the products index look.
 * Higher specificity than AdminLTE .table rules so all list tables match.
 */

/* ---------- Wrapper / chrome ---------- */
.dataTables_wrapper {
    font-size: 13px;
    color: #1f2937;
}

/* Scroll tables: bordered rounded shell with internal scroll (not page-sticky header) */
.dataTables_wrapper .dataTables_scroll {
    border: 1px solid #d7deea;
    border-radius: 8px;
    background: #fff;
    /* Do not use overflow:hidden here — it breaks DataTables'
       scrollbar-gutter padding and misaligns header vs body columns. */
}

/* Keep header/body tables on the same width basis after scroll clones them */
.dataTables_wrapper .dataTables_scrollHeadInner,
.dataTables_wrapper .dataTables_scrollHeadInner > table,
.dataTables_wrapper .dataTables_scrollBody > table {
    margin: 0 !important;
}

.dataTables_wrapper .dataTables_scrollHead table.dataTable,
.dataTables_wrapper .dataTables_scrollBody table.dataTable {
    border: 0 !important;
    border-collapse: collapse !important;
    /* Let DataTables set pixel widths — never force 100% on scroll clones */
    max-width: none !important;
}

.dataTables_wrapper .dataTables_scrollHeadInner {
    box-sizing: content-box !important;
}

.dataTables_wrapper .dataTables_scrollBody {
    max-height: 75vh;
    overflow-x: auto;
}

/* Hide FixedHeader floating clones if the plugin still creates them */
table.fixedHeader-floating,
table.fixedHeader-locked {
    display: none !important;
}

/* Non-scroll tables: same bordered shell on the table itself */
.dataTables_wrapper > table.table.dataTable,
.dataTables_wrapper > table.dataTable {
    border: 1px solid #d7deea !important;
    border-radius: 8px;
    border-collapse: separate !important;
    border-spacing: 0;
    background: #fff;
    width: 100% !important;
}

/*
 * Bootstrap .table-responsive + DataTables scrollX = double overflow and
 * header/body column width drift (units, brands, etc.). Let DT own scrolling.
 */
.table-responsive:has(.dataTables_wrapper),
.table-responsive:has(> .dataTables_wrapper) {
    border: 0;
    overflow: visible !important;
}

.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollHeadInner {
    background: #e8eef6;
}

.dataTables_wrapper table.dataTable,
.dataTables_wrapper table.dataTable th,
.dataTables_wrapper table.dataTable td {
    box-sizing: border-box !important;
}

/* ---------- Header (beat AdminLTE .table > thead > tr > th) ---------- */
.dataTables_wrapper table.table > thead > tr > th,
.dataTables_wrapper table.table > thead > tr > td,
.dataTables_wrapper table.dataTable > thead > tr > th,
.dataTables_wrapper table.dataTable thead th,
.dataTables_wrapper .dataTables_scrollHead table.table > thead > tr > th,
.dataTables_wrapper .dataTables_scrollHead table.dataTable thead th,
.dataTables_wrapper .dataTables_scrollHead table.dataTable thead td {
    background: #e8eef6 !important;
    color: #16324f !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    letter-spacing: 0.02em;
    border-bottom: 2px solid #d7deea !important;
    border-top: 0 !important;
    border-left-color: #d7deea !important;
    border-right-color: #d7deea !important;
    padding: 10px 12px !important;
    vertical-align: middle !important;
}

.dataTables_wrapper table.dataTable thead .sorting,
.dataTables_wrapper table.dataTable thead .sorting_asc,
.dataTables_wrapper table.dataTable thead .sorting_desc,
.dataTables_wrapper table.dataTable thead .sorting_asc_disabled,
.dataTables_wrapper table.dataTable thead .sorting_desc_disabled {
    background-color: #e8eef6 !important;
    color: #16324f !important;
}

/* ---------- Body cells ---------- */
.dataTables_wrapper table.table > tbody > tr > td,
.dataTables_wrapper table.dataTable > tbody > tr > td,
.dataTables_wrapper table.dataTable tbody td {
    padding: 10px 12px !important;
    vertical-align: middle !important;
    color: #1f2937 !important;
    border-color: #e8edf4 !important;
}

/* Zebra for every DataTable (with or without .table-striped) */
.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(odd) > td,
.dataTables_wrapper table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: #f7f9fc !important;
}

.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(even) > td,
.dataTables_wrapper table.dataTable.table-striped > tbody > tr:nth-of-type(even) > td {
    background-color: #fff !important;
}

/* DataTables sorted-column tint — keep row zebra */
.dataTables_wrapper table.dataTable > tbody > tr > td.sorting_1,
.dataTables_wrapper table.dataTable > tbody > tr > td.sorting_2,
.dataTables_wrapper table.dataTable > tbody > tr > td.sorting_3 {
    background-color: inherit !important;
}

.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(odd) > td.sorting_1,
.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(odd) > td.sorting_2,
.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(odd) > td.sorting_3 {
    background-color: #f7f9fc !important;
}

.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(even) > td.sorting_1,
.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(even) > td.sorting_2,
.dataTables_wrapper table.dataTable > tbody > tr:nth-of-type(even) > td.sorting_3 {
    background-color: #fff !important;
}

.dataTables_wrapper table.dataTable > tbody > tr:hover > td,
.dataTables_wrapper table.dataTable.table-hover > tbody > tr:hover > td,
.dataTables_wrapper table.dataTable > tbody > tr:hover > td.sorting_1,
.dataTables_wrapper table.dataTable > tbody > tr:hover > td.sorting_2,
.dataTables_wrapper table.dataTable > tbody > tr:hover > td.sorting_3 {
    background-color: #e7f1fb !important;
}

/* ---------- Footer ---------- */
.dataTables_wrapper table.table > tfoot > tr > td,
.dataTables_wrapper table.table > tfoot > tr > th,
.dataTables_wrapper table.dataTable tfoot td,
.dataTables_wrapper table.dataTable tfoot th {
    background: #f8fafc !important;
    padding: 10px 12px !important;
    border-top: 1px solid #d7deea !important;
    border-color: #d7deea !important;
    color: #1f2937;
    font-weight: 600;
}

/* Rounded corners on first/last header & last footer cells (non-scroll) */
.dataTables_wrapper > table.dataTable > thead > tr:first-child > th:first-child,
.dataTables_wrapper > table.dataTable > thead > tr:first-child > td:first-child {
    border-top-left-radius: 8px;
}
.dataTables_wrapper > table.dataTable > thead > tr:first-child > th:last-child,
.dataTables_wrapper > table.dataTable > thead > tr:first-child > td:last-child {
    border-top-right-radius: 8px;
}

/* ---------- Controls ---------- */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: #374151;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    min-width: 200px;
    box-shadow: none !important;
    background: #fff !important;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 2px 6px !important;
    background: #fff !important;
}

/* ---------- Action column + kebab ---------- */
.dataTables_wrapper table.dataTable td.dt-action-cell,
.dataTables_wrapper table.dataTable th.dt-action-cell,
.dataTables_wrapper .dataTables_scrollHead table.dataTable th.dt-action-cell {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center;
    white-space: nowrap;
}

.dataTables_wrapper .dt-action-kebab,
.dataTables_wrapper .product-action-kebab,
.dataTables_wrapper .contact-action-kebab {
    min-width: 30px !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 6px !important;
}

.dataTables_wrapper .dt-action-kebab:hover,
.dataTables_wrapper .dt-action-kebab:focus,
.dataTables_wrapper .product-action-kebab:hover,
.dataTables_wrapper .product-action-kebab:focus,
.dataTables_wrapper .contact-action-kebab:hover,
.dataTables_wrapper .contact-action-kebab:focus {
    background: #dbeafe !important;
}

.dataTables_wrapper .dt-action-kebab .fa-ellipsis-v,
.dataTables_wrapper .product-action-kebab .fa-ellipsis-v,
.dataTables_wrapper .contact-action-kebab .fa-ellipsis-v {
    font-size: 16px;
    color: #1f2937;
}

/* Multi-button action cells: icon only + popover label */
.dataTables_wrapper table.dataTable td.dt-action-icons {
    white-space: nowrap;
    vertical-align: middle;
}

.dataTables_wrapper .dt-action-icon-btn {
    min-width: 28px !important;
    width: auto !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
    margin-right: 2px;
}

.dataTables_wrapper .dt-action-icon-btn .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.popover.dt-action-popover {
    max-width: 220px;
    font-size: 12px;
}

.popover.dt-action-popover .popover-content {
    padding: 6px 10px;
}

/* ---------- Cell utilities ---------- */
.dataTables_wrapper table.dataTable td.dt-name-cell,
.dataTables_wrapper table.dataTable th.dt-name-cell,
.dataTables_wrapper .dataTables_scrollHead table.dataTable th.dt-name-cell,
.dataTables_wrapper table.dataTable td.contact-name-cell,
.dataTables_wrapper table.dataTable th.contact-name-cell {
    white-space: normal !important;
    min-width: 160px;
    vertical-align: middle;
    font-weight: 600;
    color: #111827;
    word-break: break-word;
    line-height: 1.35;
}

.dataTables_wrapper table.dataTable td.dt-num-cell,
.dataTables_wrapper table.dataTable td.product-num-cell,
.dataTables_wrapper table.dataTable td.contact-num-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
    color: #111827;
}

.dataTables_wrapper table.dataTable td.dt-mono-cell,
.dataTables_wrapper table.dataTable td.product-mono-cell,
.dataTables_wrapper table.dataTable td.contact-mono-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: #334155;
}

/* Detached action dropdown menus appended to body from DataTables/tables */
body > .dropdown-menu {
    width: max-content !important;
    min-width: 160px !important;
    max-width: calc(100vw - 20px) !important;
    right: auto !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
}

body > .dropdown-menu.dropdown-menu-right,
body > .dropdown-menu.dropdown-menu-left {
    right: auto !important;
}

[dir="rtl"] body > .dropdown-menu.dropdown-menu-right,
[dir="rtl"] body > .dropdown-menu.dropdown-menu-left,
body.rtl > .dropdown-menu.dropdown-menu-right,
body.rtl > .dropdown-menu.dropdown-menu-left {
    right: auto !important;
}
