/* User Management Custom Styles */
.user-management-container {
    min-height: 100vh;
    background-color: #f8fafc;
}

/* Custom DevExtreme Grid Styling */
.dx-datagrid {
    border: none !important;
    font-family: inherit;
    table-layout: fixed !important;
}

.dx-datagrid-content {
    overflow-x: auto !important;
}

.dx-datagrid .dx-datagrid-table {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 1220px !important; /* Sum of all column widths */
}

.dx-datagrid-header-panel {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e5e7eb !important;
    padding: 1rem !important;
}

.dx-datagrid-headers {
    background-color: #f8fafc !important;
    border-bottom: 2px solid #e5e7eb !important;
}

.dx-header-row {
    background-color: #f8fafc !important;
    border-bottom: 1px solid #e5e7eb !important;
    height: 48px !important;
}

.dx-header-row .dx-datagrid-text-content {
    font-weight: 600 !important;
    color: #374151 !important;
    font-size: 14px !important;
}

.dx-datagrid-content .dx-datagrid-table .dx-row {
    border-bottom: 1px solid #f3f4f6 !important;
    min-height: 56px !important;
}

.dx-datagrid-content .dx-datagrid-table .dx-row:hover {
    background-color: #f8fafc !important;
}

.dx-datagrid-rowsview .dx-selection,
.dx-datagrid-rowsview .dx-selection.dx-row:hover {
    background-color: #dbeafe !important;
}

/* Filter Row Styling - ปรับปรุงให้ดูดีขึ้น */
.dx-datagrid-filter-row {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e5e7eb !important;
    height: 52px !important;
}

.dx-datagrid-filter-row td {
    padding: 6px 8px !important;
    position: relative !important;
    vertical-align: middle !important;
}

.dx-datagrid-filter-row .dx-texteditor {
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    background-color: #ffffff !important;
    height: 38px !important;
    width: calc(100% - 4px) !important;
    min-width: 80px !important;
    margin: 0 2px !important;
}

.dx-datagrid-filter-row .dx-texteditor.dx-state-focused {
    border-color: #6b7280 !important;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.1) !important;
}

.dx-datagrid-filter-row .dx-texteditor-input {
    padding: 0.5rem !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

/* Specific column widths for filter row */
.dx-datagrid-filter-row td:nth-child(1) { /* User column */
    min-width: 280px !important;
    max-width: 280px !important;
}

.dx-datagrid-filter-row td:nth-child(2) { /* Email column */
    min-width: 220px !important;
    max-width: 220px !important;
}

.dx-datagrid-filter-row td:nth-child(3) { /* Status column */
    min-width: 110px !important;
    max-width: 110px !important;
}

.dx-datagrid-filter-row td:nth-child(4) { /* Sites column */
    min-width: 180px !important;
    max-width: 180px !important;
}

.dx-datagrid-filter-row td:nth-child(5) { /* Created column */
    min-width: 110px !important;
    max-width: 110px !important;
}

.dx-datagrid-filter-row td:nth-child(6) { /* Last Login column */
    min-width: 130px !important;
    max-width: 130px !important;
}

.dx-datagrid-filter-row td:nth-child(7) { /* Actions column */
    min-width: 120px !important;
    max-width: 120px !important;
}

.dx-datagrid-filter-row td:nth-child(7) .dx-texteditor {
    display: none !important; /* Hide filter for Actions column */
}

/* Header Filter Button Styling */
.dx-header-filter {
    color: #6b7280 !important;
    margin-left: 8px !important;
}

.dx-header-filter:hover {
    color: #374151 !important;
    background-color: #f3f4f6 !important;
}

/* Text Editor Styling */
.dx-texteditor.dx-editor-outlined {
    border: 1px solid #d1d5db !important;
    border-radius: 0.5rem !important;
    background-color: #ffffff !important;
}

.dx-texteditor.dx-editor-outlined.dx-state-focused {
    border-color: #6b7280 !important;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1) !important;
}

/* Pager Styling */
.dx-datagrid-pager {
    background-color: #ffffff !important;
    border-top: 1px solid #e5e7eb !important;
    padding: 1rem !important;
}

.dx-pages .dx-page {
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    margin: 0 0.125rem !important;
    min-width: 36px !important;
    height: 36px !important;
}

.dx-pages .dx-page.dx-selection {
    background-color: #374151 !important;
    border-color: #374151 !important;
    color: white !important;
}

.dx-pages .dx-page:hover:not(.dx-selection) {
    background-color: #f3f4f6 !important;
    border-color: #9ca3af !important;
}

/* Column Resizing */
.dx-datagrid-drag-header {
    background-color: #6b7280 !important;
}

/* No Data Message */
.dx-datagrid-nodata {
    background-color: #ffffff !important;
    color: #6b7280 !important;
    font-style: italic !important;
    padding: 2rem !important;
}

/* Loading Panel */
.dx-loadpanel-content {
    background-color: #ffffff !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
}

/* Custom animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Modal backdrop blur effect */
.modal-backdrop {
    backdrop-filter: blur(4px);
}

/* Loading state styles */
.loading-overlay {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
}

/* Responsive grid adjustments */
@media (max-width: 768px) {
    .user-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Hide less important columns on mobile */
    .dx-datagrid-headers .dx-header-row td:nth-child(n+5),
    .dx-datagrid-content .dx-data-row td:nth-child(n+5) {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .user-stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Hide even more columns on small mobile */
    .dx-datagrid-headers .dx-header-row td:nth-child(n+4),
    .dx-datagrid-content .dx-data-row td:nth-child(n+4) {
        display: none !important;
    }
}

/* Custom scrollbar for data grid */
.dx-scrollable-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.dx-scrollable-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.dx-scrollable-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dx-scrollable-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Fix column width and prevent overlap */
.dx-datagrid-headers .dx-header-row td {
    position: relative !important;
    padding: 8px 12px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    vertical-align: middle !important;
}

.dx-datagrid-content .dx-data-row td {
    position: relative !important;
    padding: 8px 12px !important;
    vertical-align: middle !important;
}

/* Specific column widths for headers */
.dx-datagrid-headers .dx-header-row td:nth-child(1) { /* User column */
    min-width: 280px !important;
    max-width: 280px !important;
    width: 280px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(2) { /* Email column */
    min-width: 220px !important;
    max-width: 220px !important;
    width: 220px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(3) { /* Status column */
    min-width: 110px !important;
    max-width: 110px !important;
    width: 110px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(4) { /* Sites column */
    min-width: 180px !important;
    max-width: 180px !important;
    width: 180px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(5) { /* Created column */
    min-width: 110px !important;
    max-width: 110px !important;
    width: 110px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(6) { /* Last Login column */
    min-width: 130px !important;
    max-width: 130px !important;
    width: 130px !important;
}

.dx-datagrid-headers .dx-header-row td:nth-child(7) { /* Actions column */
    min-width: 120px !important;
    max-width: 120px !important;
    width: 120px !important;
}

/* Apply same widths to data rows */
.dx-datagrid-content .dx-data-row td:nth-child(1) {
    min-width: 280px !important;
    max-width: 280px !important;
    width: 280px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(2) {
    min-width: 220px !important;
    max-width: 220px !important;
    width: 220px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(3) {
    min-width: 110px !important;
    max-width: 110px !important;
    width: 110px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(4) {
    min-width: 180px !important;
    max-width: 180px !important;
    width: 180px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(5) {
    min-width: 110px !important;
    max-width: 110px !important;
    width: 110px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(6) {
    min-width: 130px !important;
    max-width: 130px !important;
    width: 130px !important;
}

.dx-datagrid-content .dx-data-row td:nth-child(7) {
    min-width: 120px !important;
    max-width: 120px !important;
    width: 120px !important;
}

/* Ensure proper spacing for filter inputs */
.dx-datagrid-filter-row td {
    padding: 6px 8px !important;
    position: relative !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}

.dx-datagrid-filter-row .dx-texteditor {
    width: calc(100% - 4px) !important;
    min-width: 80px !important;
    margin: 0 2px !important;
    box-sizing: border-box !important;
}

/* Force grid container to handle overflow properly */
#usersGrid {
    width: 100% !important;
    overflow: hidden !important;
}

#usersGrid .dx-scrollable-wrapper {
    overflow-x: auto !important;
    overflow-y: auto !important;
}

/* Prevent column content from overflowing */
.dx-datagrid-content td,
.dx-datagrid-headers th {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}
