/* Theme Overrides for #e92d30 and White */
:root {
    --qiu-red: #e92d30;
    --qiu-blue: #3b82f6; /* Standard Blue for checkboxes */
}

/* Customizing DataTables to look like QIU theme */
.dataTables_wrapper .dataTables_filter {
    float: none;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.4rem 0.8rem;
    outline: none;
    transition: border-color 0.2s;
    margin: 0 !important;
    height: 38px; /* Fixed height for consistency */
}

.dataTables_wrapper .dataTables_filter input {
    width: 250px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--qiu-red);
    box-shadow: 0 0 0 1px var(--qiu-red);
}

table.dataTable {
    border-collapse: collapse !important;
    border-spacing: 0;
    width: 100% !important;
    border: 1px solid #e2e8f0;
    background-color: white;
}

table.dataTable thead th {
    background-color: #ffffff;
    color: #1e293b;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--qiu-red) !important;
    padding: 14px 15px !important;
}

table.dataTable tbody td {
    padding: 12px 15px !important;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Pagination Styling */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--qiu-red) !important;
    color: white !important;
    border: 1px solid var(--qiu-red) !important;
    border-radius: 0.375rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #fecaca !important;
    color: var(--qiu-red) !important;
    border: 1px solid var(--qiu-red) !important;
    border-radius: 0.375rem;
}

/* Advanced Filter Popover Styling */
.filter-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    width: 38px;
    height: 38px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.filter-trigger:hover {
    background-color: #f1f5f9;
    color: var(--qiu-red);
    border-color: #cbd5e1;
}

.filter-popover {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    width: 240px; /* Reduced width to match requested layout */
    padding: 12px;
    top: 45px;
    right: 0;
    display: none;
    text-transform: none;
    font-weight: normal;
}

.filter-popover.active {
    display: block;
}

.filter-search-container {
    position: relative;
    margin-bottom: 12px;
    width: 100%;
}

.filter-search {
    width: 95% !important;
    box-sizing: border-box; /* Ensures padding doesn't push width outside */
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px 8px 34px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    display: block; 
}

.filter-search:focus {
    border-color: var(--qiu-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.filter-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
}

.filter-list::-webkit-scrollbar {
    width: 6px;
}
.filter-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
.filter-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
.filter-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}

.filter-item:hover {
    background-color: #f8fafc;
}

.filter-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--qiu-blue);
    cursor: pointer;
}

/* Ensure parent doesn't clip the popover */
.bg-white.p-6.rounded-xl {
    overflow: visible !important;
}

/* Table scroll - header and body scroll together */
table.dataTable.nowrap td,
table.dataTable.nowrap th {
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_scroll,
.dataTables_scrollBody {
    overflow-x: auto !important;
}

/* Fixed left column (sticky first column) */
table.dataTable tbody tr td:first-child,
table.dataTable thead tr th:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: white;
}

table.dataTable thead tr th:first-child {
    z-index: 20;
}

table.dataTable tbody tr td:first-child {
    background-color: #f9fafb;
}

/* Stripe compatibility */
table.dataTable.stripe tbody tr.odd td:first-child,
table.dataTable.display tbody tr.odd td:first-child {
    background-color: #f9fafb;
}

/* Hover compatibility */
table.dataTable.hover tbody tr:hover td:first-child,
table.dataTable.display tbody tr:hover td:first-child {
    background-color: #f1f5f9;
}

/* Border for sticky column */
table.dataTable thead tr th:first-child {
    border-right: 2px solid #e2e8f0;
}

table.dataTable tbody tr td:first-child {
    border-right: 1px solid #e2e8f0;
}

/* Date filter styles */
.filter-date-container {
    padding: 5px 0;
}

.filter-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-date-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.filter-date-input:focus {
    border-color: var(--qiu-red);
    box-shadow: 0 0 0 2px rgba(233, 45, 48, 0.1);
}

.filter-date-container .btn {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-date-container .btn-primary {
    background: var(--qiu-red);
    color: white;
    border: none;
}

.filter-date-container .btn-primary:hover {
    background: #c0242a;
}

.filter-date-container .btn-ghost {
    background: transparent;
    color: #6b7280;
    border: 1px solid #e2e8f0;
}

.filter-date-container .btn-ghost:hover {
    background: #f1f5f9;
}