/* =============================================================================
   MwDataGrid CSS — Global Stylesheet
   Prefix: mw-dg-*
   ============================================================================= */

/* NOTE: Toolbar */
.mw-dg-toolbar {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    min-height: 44px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* NOTE: Container */
.mw-dg-container {
    overflow: auto;
    position: relative;
    width: 100%;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 120px),
        var(--mud-palette-surface);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.3),
        0 8px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.mw-dg-container::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.mw-dg-container::-webkit-scrollbar-track {
    background: transparent;
}

.mw-dg-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.mw-dg-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mw-dg-container::-webkit-scrollbar-corner {
    background: transparent;
}

/* NOTE: Table */
.mw-dg-table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    line-height: 1.35;
}

/* =============================================================================
   Header
   ============================================================================= */

.mw-dg-th {
    position: sticky;
    top: 0;
    z-index: 4;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, rgba(255, 255, 255, 0.01) 100%),
        var(--mud-palette-surface);
    padding: 0 12px;
    height: 38px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: color 0.15s ease;
}

.mw-dg-header-row .mw-dg-th:first-child {
    border-top-left-radius: 7px;
}

.mw-dg-header-row .mw-dg-th:last-child {
    border-top-right-radius: 7px;
}

.mw-dg-th--sortable {
    cursor: pointer;
    user-select: none;
}

.mw-dg-th--sortable:hover {
    color: rgba(255, 255, 255, 0.8);
}

.mw-dg-header-text {
    vertical-align: middle;
}

/* NOTE: Sort indicators */
.mw-dg-sort-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 3px;
    font-size: 0.5rem;
    vertical-align: middle;
    color: var(--mud-palette-primary);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.mw-dg-sort-desc {
    transform: rotate(180deg);
}

.mw-dg-sort-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 14px;
    height: 14px;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 7px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    margin-left: 3px;
    vertical-align: middle;
    padding: 0 3px;
}

/* =============================================================================
   Rows & Cells
   ============================================================================= */

.mw-dg-row {
    height: 36px;
    transition: background 0.1s ease;
    position: relative;
}

.mw-dg-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.mw-dg-cell {
    padding: 0 12px;
    height: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.035);
    vertical-align: middle;
    color: var(--mud-palette-text-primary);
}

/* NOTE: Hover accent — primary color bar on left edge */
.mw-dg-row > td:first-child {
    border-left: 2px solid transparent;
    transition: border-color 0.1s ease;
}

.mw-dg-row:hover > td:first-child {
    border-left-color: var(--mud-palette-primary);
}

/* =============================================================================
   Dense Mode
   ============================================================================= */

.mw-dg-dense .mw-dg-th {
    height: 32px;
    padding: 0 8px;
    font-size: 0.65rem;
}

.mw-dg-dense .mw-dg-row {
    height: 30px;
}

.mw-dg-dense .mw-dg-cell {
    padding: 0 8px;
    font-size: 0.78rem;
}

/* =============================================================================
   Variants
   ============================================================================= */

.mw-dg-bordered .mw-dg-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.035);
}

.mw-dg-bordered .mw-dg-th {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.mw-dg-striped .mw-dg-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.012);
}

.mw-dg-striped .mw-dg-row:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.04);
}

/* =============================================================================
   Filter Row
   ============================================================================= */

.mw-dg-filter-row .mw-dg-filter-cell {
    padding: 5px 8px;
    position: sticky;
    top: 38px;
    z-index: 3;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mw-dg-dense .mw-dg-filter-row .mw-dg-filter-cell {
    top: 32px;
    padding: 3px 6px;
}

.mw-dg-filter-input {
    width: 100%;
    height: 26px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--mud-palette-text-primary);
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mw-dg-filter-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.mw-dg-filter-input:focus {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px rgba(var(--mw-mc-primary), 0.12);
}

/* =============================================================================
   Column Resize Handle
   ============================================================================= */

.mw-dg-resize-handle {
    position: absolute;
    right: -1px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    cursor: col-resize;
    z-index: 5;
    border-radius: 2px;
    opacity: 0;
    background: var(--mud-palette-primary);
    transition: opacity 0.12s ease;
}

.mw-dg-th:hover .mw-dg-resize-handle {
    opacity: 0.3;
}

.mw-dg-resize-handle:hover {
    opacity: 0.7 !important;
}

.mw-dg-resize-handle:active {
    opacity: 1 !important;
}

/* =============================================================================
   Column Drag-Drop Reorder
   ============================================================================= */

.mw-dg-th--dragging {
    opacity: 0.35;
}

/* =============================================================================
   Selection
   ============================================================================= */

.mw-dg-select-th,
.mw-dg-select-cell {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    text-align: center;
    padding: 0 !important;
}

.mw-dg-row--selected {
    background: rgba(var(--mw-mc-primary), 0.06) !important;
}

.mw-dg-row--selected:hover {
    background: rgba(var(--mw-mc-primary), 0.1) !important;
}

.mw-dg-row--selected > td:first-child {
    border-left-color: var(--mud-palette-primary) !important;
}

/* =============================================================================
   Edit State
   ============================================================================= */

.mw-dg-cell--editing {
    padding: 0 !important;
    position: relative;
}

.mw-dg-cell--error {
    box-shadow: inset 0 -2px 0 var(--mud-palette-error);
}

.mw-dg-edit-input {
    width: 100%;
    height: 100%;
    padding: 0 12px;
    border: none;
    border-bottom: 2px solid var(--mud-palette-primary);
    background: rgba(var(--mw-mc-primary), 0.04);
    color: var(--mud-palette-text-primary);
    font-size: inherit;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    caret-color: var(--mud-palette-primary);
}

.mw-dg-dense .mw-dg-edit-input {
    padding: 0 8px;
}

.mw-dg-cell--error .mw-dg-edit-input {
    border-bottom-color: var(--mud-palette-error);
    caret-color: var(--mud-palette-error);
}

.mw-dg-edit-errors {
    position: absolute;
    bottom: -26px;
    left: 4px;
    z-index: 10;
    background: var(--mud-palette-background);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(var(--mw-mc-error), 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.mw-dg-edit-error {
    color: var(--mud-palette-error);
    font-size: 0.7rem;
    font-weight: 500;
}
