/* Performance CSS for School Bus System */

/* Loading indicator */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.loading.show {
    display: block;
}

/* Table optimizations */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.table thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
    white-space: nowrap;
}

/* ป้องกัน scrollbar ซ้อนกัน */
.dataTables_wrapper {
    overflow-x: visible;
}

.dataTables_wrapper .dataTables_scroll {
    overflow: visible;
}

.dataTables_wrapper .dataTables_scrollBody {
    overflow-x: visible !important;
    overflow-y: visible !important;
}

/* ปรับแต่งตาราง DataTables */
.dataTables_wrapper .dataTables_scrollHead,
.dataTables_wrapper .dataTables_scrollFoot {
    overflow: hidden;
}

/* แก้ไขปัญหา scrollbar ซ้อนกัน */
.card-body {
    overflow: visible;
}

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

/* ปรับแต่งตาราง */
.table {
    margin-bottom: 0;
    width: 100%;
    table-layout: auto;
}

.table th,
.table td {
    padding: 0.5rem;
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
    white-space: nowrap;
}

/* ปรับแต่ง DataTables pagination */
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

.dataTables_wrapper .dataTables_info {
    margin-top: 1rem;
}

/* ลบ scrollbar ที่ไม่จำเป็น */
body {
    overflow-x: auto;
}

.container-fluid {
    overflow-x: visible;
}

/* DataTables optimizations */
.dataTables_wrapper .dataTables_processing {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    margin-left: -100px;
    margin-top: -26px;
    text-align: center;
    padding: 1em 0;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Pagination controls */
.pagination-controls {
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pagination-info {
    font-size: 0.9em;
    color: #6c757d;
}

/* Button optimizations */
.btn-group-sm .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .btn-group-sm .btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .card-header .row {
        flex-direction: column;
    }
    
    .card-header .col-md-6 {
        text-align: center !important;
        margin-bottom: 10px;
    }
}

/* Lazy loading for images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[data-src].loaded {
    opacity: 1;
}

/* Virtual scrolling container */
.virtual-scroll-container {
    height: 400px;
    overflow-y: auto;
}

.virtual-scroll-item {
    height: 40px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 0 10px;
}

/* Performance indicators */
.performance-stats {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.performance-stats .stat-item {
    display: inline-block;
    margin-right: 20px;
}

.performance-stats .stat-value {
    font-weight: bold;
    color: #007bff;
}