@charset "UTF-8";
/* ================================================================
   CHRONOS UI - BOOTSTRAP 5.3 GRID ENHANCEMENTS
   Enhanced grid filters, buttons, form controls, and sort indicators
   ================================================================ */

/* Grid Table Cell Alignment */
.grid-view .table td {
    vertical-align: middle !important;
    padding: 0.75rem !important;
}

/* Button column specific styling */
.grid-view .table td.button-column {
    text-align: center !important;
    vertical-align: middle !important;
    min-width: 60px !important;
    width: 60px !important;
    padding: 0.5rem !important;
}

/* Grid Sort Indicators - Works with Yii's existing sort classes */
.grid-view .table thead th {
    position: relative;
    vertical-align: middle;
}

.grid-view .table thead th:has(a[href*="_sort"]) {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.grid-view .table thead th:has(a[href*="_sort"]):hover {
    background-color: var(--bs-secondary-bg, #f8f9fa);
}

[data-bs-theme="dark"] .grid-view .table thead th:has(a[href*="_sort"]):hover {
    background-color: var(--bs-secondary-bg, #495057);
}

/* Sort link styling - target Yii's sort-link class */
.grid-view .table thead th a[href*="_sort"],
.grid-view .table thead th a.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    padding-right: 1.8rem;
    width: 100%;
}

.grid-view .table thead th a[href*="_sort"]:hover,
.grid-view .table thead th a.sort-link:hover {
    color: var(--bs-primary, #0d6efd);
    text-decoration: none;
}

/* Sort indicators using CSS pseudo-elements */
.grid-view .table thead th a[href*="_sort"]::after,
.grid-view .table thead th a.sort-link::after {
    content: "\2195"; /* ↕ */
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: auto;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--bs-secondary, #6c757d);
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

/* Ascending state - Yii adds 'asc' class */
.grid-view .table thead th a.sort-link.asc::after,
.grid-view .table thead th a[href*="_sort"].asc::after {
    content: "\2191"; /* ↑ */
    font-size: 1.3em;
    color: var(--bs-primary, #0d6efd);
    opacity: 1;
    font-weight: 900;
}

/* Descending state - Yii adds 'desc' class */
.grid-view .table thead th a.sort-link.desc::after,
.grid-view .table thead th a[href*="_sort"].desc::after {
    content: "\2193"; /* ↓ */
    font-size: 1.3em;
    color: var(--bs-primary, #0d6efd);
    opacity: 1;
    font-weight: 900;
}

/* Active sort column highlighting */
.grid-view .table thead th:has(a.sort-link.asc),
.grid-view .table thead th:has(a.sort-link.desc),
.grid-view .table thead th:has(a[href*="_sort"].asc),
.grid-view .table thead th:has(a[href*="_sort"].desc) {
    background-color: var(--bs-primary-bg-subtle, rgba(13, 110, 253, 0.1));
    font-weight: 600;
}

[data-bs-theme="dark"] .grid-view .table thead th:has(a.sort-link.asc),
[data-bs-theme="dark"] .grid-view .table thead th:has(a.sort-link.desc),
[data-bs-theme="dark"] .grid-view .table thead th:has(a[href*="_sort"].asc),
[data-bs-theme="dark"] .grid-view .table thead th:has(a[href*="_sort"].desc) {
    background-color: rgba(13, 110, 253, 0.2);
}

/* Active sort link styling */
.grid-view .table thead th a.sort-link.asc,
.grid-view .table thead th a.sort-link.desc,
.grid-view .table thead th a[href*="_sort"].asc,
.grid-view .table thead th a[href*="_sort"].desc {
    color: var(--bs-primary, #0d6efd);
    font-weight: 600;
}

/* FontAwesome fallback for sort indicators */
.grid-view.has-fontawesome .table thead th a[href*="_sort"]::after,
.grid-view.has-fontawesome .table thead th a.sort-link::after {
    content: '\f0dc'; /* fa-sort */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
    font-weight: 900;
    font-size: 1.1em;
}

.grid-view.has-fontawesome .table thead th a.sort-link.asc::after,
.grid-view.has-fontawesome .table thead th a[href*="_sort"].asc::after {
    content: '\f0de'; /* fa-sort-up */
    font-size: 1.1em;
}

.grid-view.has-fontawesome .table thead th a.sort-link.desc::after,
.grid-view.has-fontawesome .table thead th a[href*="_sort"].desc::after {
    content: '\f0dd'; /* fa-sort-down */
    font-size: 1.1em;
}

/* Hover effects for sort indicators */
.grid-view .table thead th a[href*="_sort"]:hover::after,
.grid-view .table thead th a.sort-link:hover::after {
    opacity: 1;
    transform: translateY(-50%);
}

/* Focus states for accessibility */
.grid-view .table thead th a[href*="_sort"]:focus,
.grid-view .table thead th a.sort-link:focus {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
    border-radius: 2px;
}

/* Ascending state - Yii adds 'asc' class */
.grid-view .table thead th a.sort-link.asc::after,
.grid-view .table thead th a[href*="_sort"].asc::after {
    transform: translateY(-25%)
}

/* Descending state - Yii adds 'desc' class */
.grid-view .table thead th a.sort-link.desc::after,
.grid-view .table thead th a[href*="_sort"].desc::after {
    transform: translateY(-55%)
}

/* High contrast mode support for sort indicators */
@media (prefers-contrast: high) {
    .grid-view .table thead th:has(.sort-link.asc),
    .grid-view .table thead th:has(.sort-link.desc) {
        background-color: var(--bs-primary, #0d6efd) !important;
        color: white !important;
    }
    
    .grid-view .table thead th .sort-link.asc,
    .grid-view .table thead th .sort-link.desc {
        color: white !important;
        font-weight: 700 !important;
    }
    
    .grid-view .table thead th .sort-link.asc::after,
    .grid-view .table thead th .sort-link.desc::after {
        color: white !important;
        font-weight: 900 !important;
    }
}

/* Reduced motion support for sort indicators */
@media (prefers-reduced-motion: reduce) {
    .grid-view .table thead th .sort-link,
    .grid-view .table thead th .sort-link::after {
        transition: none !important;
    }
    
    .grid-view .table thead th .sort-link:hover::after {
        transform: translateY(-50%) !important;
    }
}

/* Mobile responsiveness for sort indicators */
@media (max-width: 768px) {
    .grid-view .table thead th .sort-link {
        padding-right: 1.2rem;
        font-size: 0.9rem;
    }
    
    .grid-view .table thead th .sort-link::after {
        font-size: 0.9em;
    }
}

/* Grid Filter Enhancements */
.grid-view .filters th {
    background-color: var(--bs-light, #f8f9fa) !important;
    border-bottom: 2px solid var(--bs-border-color, #dee2e6) !important;
    padding: 0.75rem !important;
}

[data-bs-theme="dark"] .grid-view .filters th {
    background-color: var(--bs-dark, #212529) !important;
    border-bottom-color: var(--bs-border-color, #495057) !important;
}

/* Grid Button Group Enhancements - exclude dropdown groups */
.grid-view .btn-group:not(:has(.dropdown-toggle)) {
    gap: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    border-radius: var(--bs-border-radius, 0.375rem);
    overflow: hidden;
}

.grid-view .btn-group .btn {
    border-radius: 0;
    position: relative;
    z-index: 1;
    border-left: none;
}

.grid-view .btn-group .btn:first-child {
    border-left: 1px solid var(--bs-btn-border-color, #dee2e6);
    border-top-left-radius: var(--bs-border-radius, 0.375rem);
    border-bottom-left-radius: var(--bs-border-radius, 0.375rem);
}

.grid-view .btn-group .btn:last-child {
    border-top-right-radius: var(--bs-border-radius, 0.375rem);
    border-bottom-right-radius: var(--bs-border-radius, 0.375rem);
}

.grid-view .btn-group .btn + .btn {
    margin-left: -1px;
}

.grid-view .btn-group .btn:hover,
.grid-view .btn-group .btn:focus,
.grid-view .btn-group .btn:active {
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Grid Pagination Enhancements */
.grid-view .pagination {
    margin-bottom: 0;
    gap: 0.25rem;
}

.grid-view .pagination .page-link {
    border-radius: var(--bs-border-radius, 0.375rem);
    margin: 0 0.125rem;
    transition: all 0.2s ease-in-out;
}

.grid-view .pagination .page-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Summary Text Enhancements */
.grid-view .summary {
    font-weight: 500;
    color: var(--bs-secondary, #6c757d);
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

[data-bs-theme="dark"] .grid-view .summary {
    color: var(--bs-light, #f8f9fa);
}

/* Form Control Enhancements for Grid Filters */
.grid-view .filters input.form-control,
.grid-view .filters select.form-control {
    border-radius: var(--bs-border-radius, 0.375rem);
    transition: all 0.2s ease-in-out;
    font-size: 0.875rem;
}

.grid-view .filters input.form-control:focus,
.grid-view .filters select.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    border-color: var(--bs-primary, #0d6efd);
}

/* Empty Grid State */
.grid-view .empty-grid {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--bs-secondary, #6c757d);
}

.grid-view .empty-grid .alert {
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    margin: 0 auto;
    max-width: 400px;
}

/* Table Header Enhancements */
.grid-view .table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    color: var(--bs-secondary, #6c757d);
    padding: 1rem 0.75rem;
    background-color: var(--bs-light, #f8f9fa);
    border-bottom: 2px solid var(--bs-border-color, #dee2e6);
}

[data-bs-theme="dark"] .grid-view .table thead th {
    background-color: var(--bs-dark, #212529);
    color: var(--bs-light, #f8f9fa);
    border-bottom-color: var(--bs-border-color, #495057);
}

/* Table Row Enhancements */
.grid-view .table tbody tr {
    transition: background-color 0.15s ease-in-out;
}

.grid-view .table tbody tr:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Responsive Grid Improvements */
@media (max-width: 768px) {
    /* Ensure proper table responsive behavior */
    .table-responsive {
        border: none !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Improve table spacing on mobile */
    .grid-view .table {
        margin-bottom: 0 !important;
        font-size: 0.875rem !important;
    }
    
    .grid-view .table th,
    .grid-view .table td {
        padding: 0.5rem 0.375rem !important;
        white-space: nowrap !important;
    }
    
    /* Actions column should be larger for dropdown buttons */
    .grid-view .table td.button-column {
        min-width: 60px !important;
        width: 60px !important;
        padding: 0.5rem !important;
        text-align: center !important;
    }
    
    /* Dropdown button adjustments for mobile */
    .grid-view .btn-group .dropdown-toggle {
        min-width: 40px !important;
        min-height: 40px !important;
        width: auto !important;
        height: auto !important;
        padding: 0.375rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Ensure dropdown menus are properly positioned on mobile */
    .grid-view .btn-group .dropdown-menu {
        min-width: 140px !important;
        font-size: 0.875rem !important;
    }
    
    .grid-view .btn-group .dropdown-menu .dropdown-item {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Filter row improvements */
    .grid-view .filters th {
        padding: 0.5rem 0.375rem !important;
    }
    
    .grid-view .filters input.form-control,
    .grid-view .filters select.form-control {
        font-size: 0.875rem !important;
        padding: 0.375rem 0.5rem !important;
        min-width: 120px !important;
    }
    
    /* Pagination improvements */
    .grid-view .pagination {
        justify-content: center;
        flex-wrap: wrap;
        margin: 1rem 0 !important;
    }
    
    .grid-view .pagination .page-link {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Summary text improvements */
    .grid-view .summary {
        text-align: center;
        font-size: 0.875rem;
        padding: 1rem !important;
        margin: 0 !important;
    }
    
    /* Card improvements for mobile */
    .card {
        border-radius: 0.5rem !important;
        margin: 0.5rem !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    }
    
    .card-body.p-0 {
        padding: 0 !important;
    }
    
    /* Special handling for tables with few columns */
    .grid-view .table td:first-child {
        min-width: 200px !important; /* Ensure main content column has enough space */
    }
    
    /* Ensure proper overflow behavior */
    .table-responsive .grid-view {
        overflow: visible !important;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 576px) {
    .grid-view .table {
        font-size: 0.8rem !important;
    }
    
    .grid-view .table th,
    .grid-view .table td {
        padding: 0.375rem 0.25rem !important;
    }
    
    .grid-view .btn-group .dropdown-toggle {
        min-width: 36px !important;
        min-height: 36px !important;
        width: auto !important;
        height: auto !important;
        padding: 0.25rem !important;
    }
    
    /* Button column for very small screens */
    .grid-view .table td.button-column {
        min-width: 50px !important;
        width: 50px !important;
        padding: 0.375rem !important;
    }
    
    .grid-view .filters input.form-control {
        min-width: 100px !important;
        font-size: 0.8rem !important;
    }
}

/* Grid Container Shadow */
.grid-view.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.grid-view.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Sort Indicators */
.grid-view .table thead th.sort {
    cursor: pointer;
    position: relative;
    padding-right: 2rem;
}

.grid-view .table thead th.sort::after {
    content: '\f0dc'; /* FontAwesome sort icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    transition: opacity 0.2s ease-in-out;
}

.grid-view .table thead th.sort:hover::after {
    opacity: 1;
}

.grid-view .table thead th.sort.asc::after {
    content: '\f0de'; /* FontAwesome sort-up icon */
    opacity: 1;
    color: var(--bs-primary, #0d6efd);
}

.grid-view .table thead th.sort.desc::after {
    content: '\f0dd'; /* FontAwesome sort-down icon */
    opacity: 1;
    color: var(--bs-primary, #0d6efd);
}

/* Loading State Animations */
.grid-view.grid-loading .table tbody tr {
    opacity: 0.6;
    transition: opacity 0.3s ease-in-out;
}

.grid-view.grid-loading .filters input,
.grid-view.grid-loading .filters select {
    pointer-events: none;
    opacity: 0.7;
}

/* High Contrast Mode Support for Grids */
@media (prefers-contrast: high) {
    .grid-view .table thead th {
        border-bottom: 3px solid !important;
    }
    
    .grid-view .btn-group {
        box-shadow: 0 0 0 2px var(--bs-border-color, #000);
    }
    
    .grid-view .pagination .page-link {
        border: 2px solid !important;
    }
}

/* Print Styles for Grids */
@media print {
    .grid-view .btn-group,
    .grid-view .pagination,
    .grid-view .filters {
        display: none !important;
    }
    
    .grid-view .table {
        border-collapse: collapse !important;
    }
    
    .grid-view .table th,
    .grid-view .table td {
        border: 1px solid #000 !important;
        padding: 0.5rem !important;
    }
}
