/* Tabulator Styling for StepUp School */

/* Main Tabulator container */
.tabulator {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
}

/* Header styling */
.tabulator .tabulator-header {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.tabulator .tabulator-col {
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
}

.tabulator .tabulator-col-title {
    font-weight: 600;
    color: #495057;
    padding: 12px 8px;
}

/* Row styling */
.tabulator .tabulator-row {
    border-bottom: 1px solid #dee2e6;
}

.tabulator .tabulator-row.tabulator-selectable:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.tabulator .tabulator-row.tabulator-selected {
    background-color: rgba(0, 123, 255, 0.1);
}

.tabulator .tabulator-cell {
    padding: 8px;
    border-right: 1px solid #dee2e6;
}

/* Pagination styling */
.tabulator .tabulator-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 10px;
}

.tabulator .tabulator-paginator {
    color: #495057;
}

.tabulator .tabulator-page {
    background: transparent;
    border: 1px solid #dee2e6;
    color: #007bff;
    margin: 0 2px;
    padding: 4px 8px;
    border-radius: 0.25rem;
}

.tabulator .tabulator-page:hover {
    background-color: #e9ecef;
}

.tabulator .tabulator-page.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Action buttons in cells */
.tabulator .action-buttons {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.tabulator .action-buttons .btn {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
}

/* Header filters */
.tabulator .tabulator-header-filter input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    font-size: 12px;
}

.tabulator .tabulator-header-filter input:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Loading spinner */
.tabulator .tabulator-loader {
    background: rgba(255, 255, 255, 0.8);
}

.tabulator .tabulator-loader-msg {
    color: #007bff;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tabulator {
        font-size: 0.75rem;
    }

    .tabulator .tabulator-cell {
        padding: 6px 4px;
        font-size: 0.75rem;
    }

    .tabulator .action-buttons .btn {
        padding: 1px 4px;
        font-size: 11px;
    }

    /* Make table container horizontally scrollable on mobile */
    #eleves-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Adjust column widths for mobile */
    .tabulator-col {
        min-width: 80px;
    }

    /* Ensure buttons stack properly */
    .btn-group {
        display: flex;
        flex-wrap: nowrap;
        gap: 2px;
    }

    .btn-group .btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .tabulator {
        font-size: 0.8rem;
    }

    .tabulator .tabulator-cell {
        padding: 8px 6px;
    }

    .tabulator .action-buttons .btn {
        padding: 2px 5px;
        font-size: 11px;
    }
}

/* Responsive collapse styling */
.tabulator .tabulator-responsive-collapse {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 10px;
}

.tabulator .tabulator-responsive-collapse-toggle {
    background: #007bff;
    color: white;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.tabulator .tabulator-responsive-collapse-toggle:hover {
    background: #0056b3;
}

.tabulator .tabulator-responsive-collapse table {
    width: 100%;
    font-size: 0.85rem;
}

.tabulator .tabulator-responsive-collapse table tr {
    border-bottom: 1px solid #dee2e6;
}

.tabulator .tabulator-responsive-collapse table tr:last-child {
    border-bottom: none;
}

.tabulator .tabulator-responsive-collapse table td {
    padding: 8px;
}

.tabulator .tabulator-responsive-collapse table td:first-child {
    font-weight: 600;
    color: #495057;
    width: 40%;
}

/* Ensure horizontal scroll on small devices */
@media (max-width: 576px) {
    .card-body {
        padding: 0 !important;
    }

    #eleves-table {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tabulator {
        min-width: 100%;
    }

    /* Stack filters vertically on very small screens */
    #filters .col-md-3 {
        margin-bottom: 10px;
    }

    /* Adjust global search for mobile */
    #global-search {
        width: 100% !important;
        margin-bottom: 10px;
    }
}

/* Selection checkbox styling */
.tabulator .tabulator-row-select {
    width: 16px;
    height: 16px;
}

/* Sort arrows */
.tabulator .tabulator-col.tabulator-sortable .tabulator-arrow {
    color: #6c757d;
}

.tabulator .tabulator-col.tabulator-sortable.tabulator-col-sorter-asc .tabulator-arrow,
.tabulator .tabulator-col.tabulator-sortable.tabulator-col-sorter-desc .tabulator-arrow {
    color: #007bff;
}

/* Badge styling in cells */
.tabulator .badge {
    display: inline-block;
    padding: 0.25em 0.4em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.tabulator .badge.bg-primary {
    color: #fff;
    background-color: #007bff;
}

.tabulator .badge.bg-success {
    color: #fff;
    background-color: #28a745;
}

.tabulator .badge.bg-danger {
    color: #fff;
    background-color: #dc3545;
}

.tabulator .badge.bg-info {
    color: #fff;
    background-color: #17a2b8;
}

.tabulator .badge.bg-warning {
    color: #212529;
    background-color: #ffc107;
}

/* Mobile-specific table improvements */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Improve button group display on mobile */
.tabulator .btn-group {
    display: inline-flex;
    gap: 4px;
}

.tabulator .btn-sm {
    white-space: nowrap;
}

/* Better badge visibility on mobile */
@media (max-width: 768px) {
    .tabulator .badge {
        font-size: 0.7rem;
        padding: 0.2em 0.3em;
    }
}

/* Ensure action buttons remain visible */
.tabulator-cell .btn-group {
    min-width: max-content;
}

/* Improve row selection on touch devices */
@media (hover: none) and (pointer: coarse) {
    .tabulator .tabulator-row.tabulator-selectable {
        cursor: pointer;
    }

    .tabulator .tabulator-cell {
        padding: 12px 8px;
    }
}
