/* style.css - custom styles */
/* static\css\style.css */
body {
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
}

h1, h2 {
    color: #343a40;
}

/* Enhanced Fixed Columns Table Styles */
.fixed-columns-wrapper {
    position: relative;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.fixed-columns-container {
    display: flex;
    width: 100%;
    max-height: 70vh;
    overflow: hidden;
}

.fixed-columns-left {
    flex-shrink: 0;
    border-right: 2px solid #007bff;
    background: #f8f9fa;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.scrollable-columns-right {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

.fixed-columns-table, .scrollable-columns-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 0;
}

.fixed-columns-table th, .fixed-columns-table td,
.scrollable-columns-table th, .scrollable-columns-table td {
    border: 1px solid #dee2e6;
    padding: 6px 4px; /* Reduced padding */
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    min-width: 60px; /* Reduced from 100px */
    font-size: 0.9em; /* Smaller font */
}

.fixed-columns-table th, .scrollable-columns-table th {
    background-color: #343a40;
    color: white;
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 600;
}

.fixed-columns-table tbody tr:nth-child(even),
.scrollable-columns-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.fixed-columns-table tbody tr:hover,
.scrollable-columns-table tbody tr:hover {
    background-color: #e9ecef;
}

/* Column highlighting on hover */
.scrollable-columns-table th:hover,
.scrollable-columns-table td:hover {
    background-color: #fff3cd !important;
    cursor: pointer;
}

/* Scroll indicators */
.scroll-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scroll-indicator.left {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.1), transparent);
}

.scroll-indicator.right {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.1), transparent);
}

.scroll-indicator.visible {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .fixed-columns-container {
        max-height: 50vh;
    }
    
    .fixed-columns-table th, .fixed-columns-table td,
    .scrollable-columns-table th, .scrollable-columns-table td {
        padding: 4px 2px; /* Further reduced padding for mobile */
        font-size: 0.8rem; /* Smaller font for mobile */
        min-width: 45px; /* Smaller minimum width for mobile */
    }
    
    .table-responsive-horizontal th,
    .table-responsive-horizontal td {
        padding: 4px 2px !important;
        font-size: 0.8rem !important;
        min-width: 45px !important;
    }
}

/* Navigation buttons for better UX */
.table-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 0.375rem;
}

.scroll-buttons {
    display: flex;
    gap: 5px;
}

.scroll-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.scroll-btn:hover {
    background: #0056b3;
}

.scroll-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.table-info {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Additional styling for the report table */
table#data_table {
    margin-top: 20px;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed; /* Force fixed layout for consistent column widths */
}

table#data_table th, table#data_table td {
    border: 1px solid #dee2e6;
    padding: 6px 4px; /* Reduced padding */
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table#data_table th {
    background-color: #343a40;
    color: #fff;
    font-size: 0.85em;
    font-weight: 600;
}

table#data_table td {
    font-size: 0.9em;
}




body {
    padding-top: 20px;
    padding-bottom: 20px;
}

h1, h2 {
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th, table td {
    padding: 8px;
    text-align: center;
    vertical-align: middle;
}

table thead th {
    background-color: #343a40;
    color: #fff;
}

.table-custom {
    border: 1px solid #dee2e6;
}

.table-custom tbody tr:nth-of-type(odd) {
    background-color: #f9f9f9;
}

.table-custom tbody tr:hover {
    background-color: #f1f1f1;
}

.subtotal-row {
    font-weight: bold;
    background-color: #e2f0d9 !important;
}

.date-total-row {
    font-weight: bold;
    background-color: #fce4d6 !important;
}

@media (max-width: 767.98px) {
    .form-row > [class*="col-"] {
        margin-bottom: 15px;
    }
}

/* New CSS for clickable cells */
.clickable-cell {
    cursor: pointer;
    background-color: #f7ebe9; /* light green background */
}

.clickable-cell:hover {
    background-color: #d4efdf;
}

/* Performance optimization styles */
.table-loading {
    opacity: 0.6;
    pointer-events: none;
}

.pagination-controls {
    margin: 20px 0;
}

.pagination-controls .pagination {
    margin-bottom: 10px;
}

/* Improved table rendering for large datasets */
#data_table {
    table-layout: auto;
    width: 100%;
    min-width: 600px; /* Reduced from 800px */
}

#data_table th, #data_table td {
    word-wrap: break-word;
    white-space: nowrap;
    min-width: 50px; /* Reduced from 100px */
    padding: 4px 6px; /* Further reduced padding */
}

#data_table th {
    white-space: normal;
    font-size: 11px;
    line-height: 1.2;
    vertical-align: middle;
}

/* Fix for table cell display */
#data_table td {
    white-space: nowrap;
    padding: 4px 6px; /* Reduced padding */
    text-align: center;
    border: 1px solid #dee2e6;
}

/* Ensure numeric columns are right-aligned */
#data_table td:not(:first-child):not(:nth-child(2)):not(:nth-child(3)) {
    text-align: right;
}

/* Special styling for total rows */
#data_table tr:has(td:contains("Date Total")) td,
#data_table tr:has(td:contains("Subtotal")) td {
    background-color: #f8f9fa;
    font-weight: 600;
    border-top: 2px solid #343a40;
}

/* Loading spinner styles */
.table-processing {
    position: relative;
}

.table-processing::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
}

/* Optimize rendering for large tables */
.table-optimized {
    contain: layout style paint;
    will-change: transform;
}

/* Horizontal scrolling for tables with many columns */
.table-responsive-horizontal {
    overflow-x: auto;
    overflow-y: visible;
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

.table-responsive-horizontal table {
    margin-bottom: 0;
    border: 0;
}

/* Better column header styling for grouped reports */
.table-responsive-horizontal th {
    position: sticky;
    top: 0;
    background-color: #343a40 !important;
    color: white !important;
    z-index: 10;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-align: center;
    vertical-align: top; /* Changed from middle to top */
    min-width: 60px; /* Reduced from 120px */
    max-width: none;
    word-wrap: break-word;
    white-space: normal; /* Allow text wrapping */
    line-height: 0.9; /* Tighter line height */
    padding: 4px 2px; /* Further reduced padding */
    overflow: visible; /* Allow overflow for multi-line */
    text-overflow: unset;
    font-size: 0.65em; /* Even smaller font for headers */
    height: auto;
    min-height: 30px;
    max-height: 45px;
}

/* Optimized cell styling */
.table-responsive-horizontal td {
    min-width: 60px; /* Consistent with headers */
    padding: 6px 4px; /* Reduced padding */
    text-align: center;
    vertical-align: middle;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* First column (date) styling */
.table-responsive-horizontal th:first-child,
.table-responsive-horizontal td:first-child {
    position: sticky;
    left: 0;
    background-color: #f8f9fa;
    z-index: 11;
    border-right: 2px solid #dee2e6;
    font-weight: 600;
}

.table-responsive-horizontal th:first-child {
    background-color: #343a40 !important;
    color: white !important;
}

/* Clickable cell styling */
.clickable-cell {
    cursor: pointer;
    background-color: #e3f2fd !important;
    transition: background-color 0.2s ease;
}

.clickable-cell:hover {
    background-color: #bbdefb !important;
    border: 2px solid #2196f3;
}

/* Summary row styling */
.table-responsive-horizontal tr:has(td:contains("Date Total")),
.table-responsive-horizontal tr:has(td:contains("Subtotal")) {
    background-color: #f1f3f4 !important;
    font-weight: 600;
}

/* Ensure table doesn't get too compressed */
.table-responsive-horizontal table {
    min-width: 100%;
    width: max-content;
}

/* Scrollbar styling for better UX */
.table-responsive-horizontal::-webkit-scrollbar {
    height: 12px;
}

.table-responsive-horizontal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.table-responsive-horizontal::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.table-responsive-horizontal::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* For Firefox */
.table-responsive-horizontal {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* DataTables specific styling for horizontal scroll */
.dataTables_wrapper .table-responsive-horizontal .dataTables_scrollBody {
    overflow-x: auto;
    overflow-y: visible;
}

.dataTables_wrapper .table-responsive-horizontal table {
    width: auto !important;
}

/* Responsive text for smaller screens */
@media (max-width: 768px) {
    .table-responsive-horizontal table th,
    .table-responsive-horizontal table td {
        min-width: 50px; /* Reduced from 100px */
        font-size: 14px;
        padding: 4px; /* Reduced padding */
    }
    
    .table-responsive-horizontal table th.date-column,
    .table-responsive-horizontal table td.date-column {
        min-width: 70px; /* Reduced from 90px */
    }
    
    .table-responsive-horizontal table th.vehicle-column,
    .table-responsive-horizontal table td.vehicle-column {
        min-width: 50px; /* Reduced from 70px */
    }
}

/* Loading indicator for horizontal scroll tables */
.table-responsive-horizontal.loading {
    position: relative;
}

.table-responsive-horizontal.loading::before {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
    font-weight: bold;
}

/* Scroll shadow effects for better UX */
.table-responsive-horizontal.scroll-shadow-left::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 10px;
    height: 100%;
    background: linear-gradient(to right, rgba(0,0,0,0.15), transparent);
    pointer-events: none;
    z-index: 2;
}

.table-responsive-horizontal.scroll-shadow-right::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 100%;
    background: linear-gradient(to left, rgba(0,0,0,0.15), transparent);
    pointer-events: none;
    z-index: 2;
}

/* Enhanced table headers for horizontal scroll */
.table-responsive-horizontal table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background-color: #343a40 !important;
    color: #fff !important;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
}

/* Column width indicators */
.table-responsive-horizontal table th.date-column {
    background-color: #495057 !important;
}

.table-responsive-horizontal table th.total-column {
    background-color: #28a745 !important;
}

.table-responsive-horizontal table th.vehicle-column {
    background-color: #6c757d !important;
}

/* Mobile responsiveness for horizontal scroll */
@media (max-width: 576px) {
    .table-responsive-horizontal {
        font-size: 12px;
    }
    
    .table-responsive-horizontal table th,
    .table-responsive-horizontal table td {
        min-width: 40px; /* Reduced from 80px */
        padding: 2px; /* Reduced padding */
    }
    
    .table-responsive-horizontal::-webkit-scrollbar {
        height: 8px;
    }
}

/* Print styles - ensure tables print properly */
@media print {
    .table-responsive-horizontal {
        overflow: visible !important;
        width: auto !important;
    }
    
    .table-responsive-horizontal table {
        width: 100% !important;
        min-width: auto !important;
    }
    
    .table-responsive-horizontal table th,
    .table-responsive-horizontal table td {
        min-width: auto !important;
        white-space: normal !important;
        font-size: 8pt !important;
        padding: 2px !important;
    }
}

/* FINAL OVERRIDE: Aggressive column width reduction for traffic count tables */
.table-responsive-horizontal #data_table th,
.table-responsive-horizontal #data_table td,
#data_table.table th,
#data_table.table td,
#data_table th,
#data_table td {
    min-width: 45px !important;
    max-width: 150px !important;
    padding: 3px 4px !important;
    font-size: 0.85rem !important;
    text-align: center !important;
    border: 1px solid #dee2e6 !important;
}

/* Header-specific styling for multi-line support */
.table-responsive-horizontal #data_table th,
#data_table th {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    height: auto !important;
    min-height: 30px !important;
    max-height: 45px !important;
    overflow: visible !important;
    text-overflow: unset !important;
    font-size: 0.65rem !important;
    line-height: 0.9 !important;
    padding: 3px 2px !important;
    vertical-align: top !important;
    background-color: #343a40 !important;
    color: white !important;
}

/* Body cell styling - keep single line */
.table-responsive-horizontal #data_table td,
#data_table td {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    vertical-align: middle !important;
}

/* Specific column type optimizations */
.table-responsive-horizontal #data_table th:first-child,
.table-responsive-horizontal #data_table td:first-child,
#data_table th:first-child,
#data_table td:first-child {
    min-width: 80px !important; /* Date column */
    max-width: 100px !important;
}

.table-responsive-horizontal #data_table th:nth-child(2),
.table-responsive-horizontal #data_table td:nth-child(2),
.table-responsive-horizontal #data_table th:nth-child(3),
.table-responsive-horizontal #data_table td:nth-child(3),
#data_table th:nth-child(2),
#data_table td:nth-child(2),
#data_table th:nth-child(3),
#data_table td:nth-child(3) {
    min-width: 60px !important; /* Vehicle category/type columns */
    max-width: 80px !important;
}

.table-responsive-horizontal #data_table th:nth-child(n+4),
.table-responsive-horizontal #data_table td:nth-child(n+4),
#data_table th:nth-child(n+4),
#data_table td:nth-child(n+4) {
    min-width: 40px !important; /* Numeric data columns */
    max-width: 60px !important;
    text-align: center !important;
}

/* Force table layout for performance */
.table-responsive-horizontal #data_table,
#data_table {
    table-layout: fixed !important;
    width: auto !important;
    min-width: 500px !important;
}

/* Mobile ultra-compact mode */
@media (max-width: 768px) {
    .table-responsive-horizontal #data_table th,
    .table-responsive-horizontal #data_table td,
    #data_table th,
    #data_table td {
        min-width: 35px !important;
        padding: 2px 3px !important;
        font-size: 0.75rem !important;
    }
    
    .table-responsive-horizontal #data_table th:first-child,
    .table-responsive-horizontal #data_table td:first-child,
    #data_table th:first-child,
    #data_table td:first-child {
        min-width: 60px !important;
    }
}
