﻿.grid-data-table-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0; /* Allow flex item to shrink below content size */
    overflow: hidden;
}

.grid-data-table-toolbar {
    padding: 0.5rem;
    padding-left: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* Prevent toolbar from shrinking */
    min-height: fit-content;
}

/* Updated search box styling with subtle background */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 10px;
}

    .search-box label {
        color: var(--main-font-color);
        font-size: var(--main-font-size);
    }

    .search-box input {
        padding: var(--input-padding-vertical) var(--input-padding-horizontal);
        min-width: 180px;
        border: 1px solid var(--input-border-color);
        background-color: var(--input-background-color);
        border-radius: var(--input-border-radius);
        transition: all 0.2s ease;
        color: var(--input-font-color);
    }
        
        .search-box input:hover {
            outline: none;
            background-color: var(--input-background-color-hover);
            border: 1px solid var(--input-border-color-hover);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }

        .search-box input:focus {
            outline: none;
            background-color: var(--input-background-color-active);
            border: 1px solid var(--input-border-color-active);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        }

.grid-data-table-responsive {
    flex: 1; /* Take remaining space */
    min-height: 0; /* Allow shrinking */
    overflow: auto;
    position: relative; /* Required for sticky positioning */
}

/* Table styling with intelligent layout handling */
.grid-data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* Apply fixed layout only when columns have specified widths */
.grid-data-table.has-fixed-widths {
    table-layout: fixed;
}

/* Use auto layout when no widths are specified for better content fitting */
.grid-data-table:not(.has-fixed-widths) {
    table-layout: auto;
}

    /* Headers with solid background and enhanced sticky positioning */
    .grid-data-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--datatable-header-background-color);
        height: var(--datatable-header-height);
    }

        .grid-data-table thead th {
            padding: 0.5rem;
            font-weight: var(--datatable-header-font-weight);
            text-align: left;
            white-space: nowrap;
            color: var(--datatable-header-font-color);
            letter-spacing: 0.5px;
            font-size: var(--datatable-header-font-size);
            border-bottom: 2px solid var(--datatable-header-border-bottom-color);
            background: var(--datatable-header-background-color); /* Ensure solid background */
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            box-sizing: border-box;
            position: sticky;
            top: 0;
            z-index: 11;
            overflow: hidden;
            text-overflow: ellipsis;
        }

    .grid-data-table th.sortable {
        cursor: pointer;
        user-select: none;
        transition: background 0.2s ease;
    }

        .grid-data-table th.sortable:hover {
            background: var(--datatable-header-background-color-hover);
        }

.sort-icon {
    margin-left: 10px;
    display: inline-block;
    color: var(--datatable-arrows-color);
    font-size: var(--datatable-header-font-size);
    line-height: 100%;
}

.sort-placeholder {
    opacity: 0.3;
}

/* Enhanced Column Resizing Functionality */
.resizable-column {
    position: relative;
    overflow: hidden;
}

.column-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 15px; /* Space for resize handle */
    overflow: hidden;
    width: 100%;
}

.column-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    border-right: 3px solid transparent;
    transition: all 0.2s ease;
    z-index: 15;
    touch-action: none;
}

.column-resize-handle:hover {
    border-right-color: var(--datatable-resize-handle-color, #0066cc);
    background: var(--datatable-resize-handle-background, rgba(0, 102, 204, 0.1));
}

.column-resize-handle:active {
    border-right-color: var(--datatable-resize-handle-active-color, #004499);
    background: var(--datatable-resize-handle-active-background, rgba(0, 68, 153, 0.3));
}

/* Visual feedback during resize operation */
.grid-data-table.resizing {
    user-select: none;
    cursor: col-resize;
}

.grid-data-table.resizing * {
    user-select: none;
    pointer-events: none;
}

.grid-data-table.resizing .column-resize-handle {
    pointer-events: auto;
    border-right-color: var(--datatable-resize-handle-active-color, #004499);
    background: var(--datatable-resize-handle-active-background, rgba(0, 68, 153, 0.3));
}

/* Resize constraint indicators */
.grid-data-table.resizing th.resize-constrained {
    background: var(--datatable-resize-constrained-background, rgba(255, 193, 7, 0.1));
    border-left: 2px solid var(--datatable-resize-constrained-border, #ffc107);
}

.grid-data-table.resizing th.resize-min-width {
    background: var(--datatable-resize-min-background, rgba(220, 53, 69, 0.1));
    border-left: 2px solid var(--datatable-resize-min-border, #dc3545);
}

/* Sorting interaction improvements for resizable columns */
.grid-data-table th.sortable .column-header-content {
    pointer-events: none;
}

.grid-data-table th.sortable {
    pointer-events: auto;
}

.grid-data-table th.sortable .column-resize-handle {
    pointer-events: auto;
}

/* FIXED ROW HEIGHT: 32px */
/* Force consistent row height regardless of content */
.grid-data-table tbody tr {
    height: 32px; /* Fixed height for all rows */
    transition: background 0.2s ease;
    cursor: pointer;
}

    .grid-data-table tbody tr:nth-child(even) {
        background: var(--datatable-row-background-color-even);
    }

    .grid-data-table tbody tr:hover {
        background: var(--datatable-row-background-color-hover);
    }

    .grid-data-table tbody tr.selected {
        background: var(--datatable-row-background-color-selected);
    }

.grid-data-table td {
    height: 32px; /* Same fixed height as tr */
    padding-top: var(--datatable-row-padding-top) !important;
    padding-bottom: var(--datatable-row-padding-bottom) !important;
    padding-left: var(--datatable-row-padding-left) !important;
    padding-right: var(--datatable-row-padding-right) !important;
    border-top: 1px solid var(--datatable-row-border-top-color);
    white-space: nowrap;
    line-height: 100%;
    font-size: var(--datatable-row-font-size);
    background: var(--datatable-row-background-color);
    vertical-align: middle; /* Center content vertically within fixed height */
    overflow: hidden; /* Prevent content from breaking layout */
    text-overflow: ellipsis;
    box-sizing: border-box;
}

/* Enhanced cell content handling for fixed width tables */
.grid-data-table.has-fixed-widths .cell-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    display: block;
}

/* For auto layout tables, allow more flexible content handling */
.grid-data-table:not(.has-fixed-widths) .cell-content {
    display: block;
    max-width: 100%;
}

/* For templates that need ellipsis behavior */
.ellipsis-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    max-width: 100%;
}

/* Custom scrollbar */
.grid-data-table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.grid-data-table-responsive::-webkit-scrollbar-track {
    border-radius: 4px;
}

.grid-data-table-responsive::-webkit-scrollbar-thumb {
    background: var(--datatable-row-scrollbarthumb-color);
    border-radius: 4px;
    transition: background 0.3s ease;
}

    .grid-data-table-responsive::-webkit-scrollbar-thumb:hover {
        background: var(--datatable-row-scrollbarthumb-color-hover);
    }

/* Mozilla Firefox scrollbar styling */
@supports (scrollbar-width: thin) {
    .grid-data-table-responsive {
        scrollbar-width: thin;
        scrollbar-color: rgba(13, 31, 36, 0.3) rgba(0, 0, 0, 0.05);
    }
}

/* Enhanced actions column handling */
.actions-column {
    white-space: nowrap;
    text-align: right;
    height: 32px; /* Match the fixed row height */
    vertical-align: middle;
    min-width: 80px; /* Ensure minimum width for action buttons */
}

/* For fixed layout tables, set a specific width for actions */
.grid-data-table.has-fixed-widths .actions-column {
    width: 120px; /* Fixed width when table uses fixed layout */
}

/* For auto layout tables, use minimum width */
.grid-data-table:not(.has-fixed-widths) .actions-column {
    width: auto;
    min-width: 100px;
}

/* ACTION BUTTON STYLING FOR 32px ROW HEIGHT */
/* Ensure action buttons fit within the 32px row height */
.actions-column button,
.actions-column .btn,
.actions-column input[type="button"],
.actions-column input[type="submit"] {
    height: 26px; /* 6px less than row height for breathing room */
    max-height: 26px;
    padding: 2px 8px; /* Compact padding to fit within height */
    font-size: 0.75rem; /* Smaller font for compact design */
    line-height: 1.1;
    box-sizing: border-box;
    vertical-align: middle;
    border-radius: 3px; /* Slightly smaller border radius */
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 1px; /* Minimal margin between multiple buttons */
    min-width: 26px; /* Ensure minimum clickable area */
}

/* Icon-only buttons - square and compact */
.actions-column .btn-icon,
.actions-column button.icon-only {
    width: 26px;
    height: 26px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem; /* Small icon size */
}

/* Small button variation */
.actions-column .btn-sm,
.actions-column button.small {
    height: 22px;
    max-height: 22px;
    padding: 1px 6px;
    font-size: 0.65rem;
    min-width: 22px;
}

/* Extra small button variation */
.actions-column .btn-xs,
.actions-column button.extra-small {
    height: 18px;
    max-height: 18px;
    padding: 0 4px;
    font-size: 0.6rem;
    min-width: 18px;
}

/* Medium button variation (slightly larger than default) */
.actions-column .btn-md,
.actions-column button.medium {
    height: 28px;
    max-height: 28px;
    padding: 3px 10px;
    font-size: 0.8rem;
    min-width: 28px;
}

/* Text content in buttons should not wrap */
.actions-column button span,
.actions-column .btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Handle button groups in action column */
.actions-column .btn-group {
    display: inline-flex;
    gap: 1px;
}

    .actions-column .btn-group button {
        margin: 0;
        border-radius: 0;
    }

    .actions-column .btn-group button:first-child {
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
    }

    .actions-column .btn-group button:last-child {
        border-top-right-radius: 3px;
        border-bottom-right-radius: 3px;
    }

.no-data {
    text-align: center;
    padding: 1.5rem !important;
    color: rgba(0, 0, 0, 0.5);
    font-style: italic;
    height: auto !important; /* Allow no-data row to be taller if needed */
}

/* Additional CSS for CustomGrid integration */
.cases-dashboard-main-cases,
.cases-dashboard-onhold-cases {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Wrapper for grid items with DataTable */
.cases-dashboard-grid-item-wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.cases-dashboard-grid-item-bottom {
    flex: 1;
    min-height: 0;
    display: flex;
}

/* CSS Variables for customization */
:root {
    --datatable-resize-handle-color: #0066cc;
    --datatable-resize-handle-background: rgba(0, 102, 204, 0.1);
    --datatable-resize-handle-active-color: #004499;
    --datatable-resize-handle-active-background: rgba(0, 68, 153, 0.2);
    --datatable-resize-constrained-background: rgba(255, 193, 7, 0.1);
    --datatable-resize-constrained-border: #ffc107;
    --datatable-resize-min-background: rgba(220, 53, 69, 0.1);
    --datatable-resize-min-border: #dc3545;
}

/* Responsive behavior for smaller screens */
@media (max-width: 768px) {
    .grid-data-table-container {
        font-size: 0.9rem;
    }
    
    .column-resize-handle {
        width: 8px; /* Larger touch target on mobile */
    }
    
    .grid-data-table thead th {
        padding: 0.25rem;
        font-size: 0.85rem;
    }
    
    .grid-data-table td {
        padding: 0.25rem;
        font-size: 0.85rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .grid-data-table *,
    .column-resize-handle,
    .actions-column button {
        transition: none !important;
    }
}

/* Focus indicators for accessibility */
.column-resize-handle:focus-visible {
    outline: 2px solid var(--datatable-resize-handle-active-color, #004499);
    outline-offset: 1px;
}

.grid-data-table th.sortable:focus-visible {
    outline: 2px solid var(--datatable-header-focus-color, #0066cc);
    outline-offset: -2px;
}

/* Print styles */
@media print {
    .column-resize-handle {
        display: none;
    }
    
    .grid-data-table-responsive {
        overflow: visible;
    }
    
    .grid-data-table {
        page-break-inside: avoid;
    }
}

.result-count {
    margin-left: 10px;
    color: #666;
    font-size: 0.9em;
}