/* --- Datatable Component --- */
.ce-table-container {
    background:
        /* Shadow Covers (moves with content) */
        linear-gradient(to right, var(--theme-content-bg, #ffffff) 30%, transparent),
        linear-gradient(to left, var(--theme-content-bg, #ffffff) 30%, transparent),
        /* Shadows (fixed) */
        linear-gradient(to right, rgba(0, 0, 0, 0.1) 0%, transparent 100%),
        linear-gradient(to left, rgba(0, 0, 0, 0.1) 0%, transparent 100%);
    background-position: left center, right center, left center, right center;
    background-repeat: no-repeat;
    background-color: var(--theme-content-bg, #ffffff);
    background-size: 40px 100%, 40px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
    
    border: 1px dashed var(--theme-content-border-strong, #e2e8f0);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.ce-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
    color: var(--theme-content-text-main, #1e293b);
}

.ce-table th, .ce-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--theme-content-border, #e2e8f0);
    height: 52px; /* Enforces a minimum row height of 32px content + 12px vertical padding */
}

.ce-table th {
    /* Use translucent overlay so container scroll shadows remain visible */
    background: rgba(15, 23, 42, 0.06);
    background: color-mix(in srgb, var(--theme-content-text-main, #1e293b) 6%, transparent);
    font-weight: 600;
    color: var(--theme-content-heading, #0f172a);
    border-bottom: 2px solid var(--theme-content-border-strong, #cbd5e1);
}

/* Options */

.ce-table.ce-table-hover tbody tr:hover {
    background-color: rgba(15, 23, 42, 0.06);
    background-color: color-mix(in srgb, var(--theme-content-text-main, #1e293b) 6%, transparent);
    transition: background-color 0.2s ease;
}

.ce-table.ce-table-bordered th,
.ce-table.ce-table-bordered td {
    border-right: 1px solid var(--theme-content-border, #e2e8f0);
}

.ce-table.ce-table-bordered th:last-child,
.ce-table.ce-table-bordered td:last-child {
    border-right: none;
}

/* Empty State */
.ce-table-empty {
    text-align: center;
    padding: 32px !important;
    color: var(--theme-content-text-muted, #64748b);
    font-style: italic;
}

/* Translucent Buttons for Scroll Shadow Visibility */
.ce-table .ce-btn-secondary {
    background-color: rgba(15, 23, 42, 0.05);
    background-color: color-mix(in srgb, var(--theme-content-text-main, #1e293b) 5%, transparent);
    border-color: transparent;
}
.ce-table .ce-btn-secondary:hover:not(:disabled) {
    background-color: rgba(15, 23, 42, 0.1);
    background-color: color-mix(in srgb, var(--theme-content-text-main, #1e293b) 10%, transparent);
}

/* --- Datatable Cell Utilities --- */
.ce-table-cell-center {
    display: flex;
    justify-content: center;
}

.ce-table-lock {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 32px;
    color: var(--theme-content-text-muted, #94a3b8);
}

.ce-table-status-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ce-table-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Action Buttons inside Datatables */
.ce-table .ce-btn.ce-btn-rectangle.ce-table-action-btn {
    padding: 4px 12px;
    font-size: 0.85rem;
}

.ce-table .ce-btn.ce-table-ce-btn-warning {
    background-color: var(--warning-color, #facc15);
    color: #000000;
    border-color: var(--warning-color, #facc15);
}

/* --- Datatable Component Layout Utilities --- */
.ce-dt-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ce-dt-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 300px;
}

.ce-dt-search-icon {
    position: absolute;
    left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ce-dt-search-input {
    width: 100%;
    padding-left: 36px !important;
    padding-right: 36px !important;
}

.ce-dt-search-clear {
    position: absolute;
    right: 6px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px;
    cursor: pointer;
    color: var(--theme-content-text-muted);
    /* display: none; is handled by inline :style or Alpine x-show */
    align-items: center;
    justify-content: center;
}

/* Scoped to the parent htmx-request state */
.ce-dt-spinner-overlay { 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.2s; 
    position: absolute; 
    inset: 0; 
    background: rgba(255,255,255,0.6); 
    z-index: 10; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 8px; 
    backdrop-filter: blur(1px); 
}

.ce-dt-wrapper.htmx-request .ce-dt-spinner-overlay { 
    opacity: 1; 
    pointer-events: all; 
}

@keyframes ce-spin { 
    100% { transform: rotate(360deg); } 
}

.ce-dt-th-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ce-dt-sort-btn {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    outline: none;
}

.ce-dt-th-label {
    font-weight: 600;
    color: var(--theme-content-heading);
}

.ce-dt-th-label-active {
    font-weight: 600;
    color: var(--theme-ui-primary);
}

.ce-dt-th-active {
    background-color: rgba(0,0,0,0.02);
}

.ce-dt-pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.5rem;
}

.ce-dt-pagination-info {
    font-size: 0.875rem;
    color: var(--theme-content-text-muted, #64748b);
}

.ce-dt-pagination-controls {
    display: flex;
    gap: 0.5rem;
}

/* --- Datatable Column Filters --- */
.ce-dt-filter-row {
    background: var(--theme-content-bg, #ffffff);
}

.ce-dt-filter-row th {
    padding-top: 4px;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--theme-content-border-strong, #cbd5e1);
}

.ce-dt-filter-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.ce-dt-filter-input {
    width: 100%;
    padding-left: 28px !important;
    padding-right: 28px !important;
    font-weight: 400;
}

.ce-dt-filter-icon {
    position: absolute;
    left: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--theme-content-text-muted, #94a3b8);
}
