/* Mobile-Friendly Table Improvements */

/* Default table styling improvements */
.table-responsive {
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: none;
}

/* Mobile table card approach - transforms tables into cards on small screens */
@media (max-width: 767px) {
    /* Hide table headers on mobile */
    .mobile-table thead {
        display: none;
    }
    
    /* Transform table rows into cards */
    .mobile-table tbody tr {
        display: block;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        margin-bottom: 1rem;
        box-shadow: var(--card-shadow);
        padding: 1rem;
    }
    
    /* Transform table cells into labeled data */
    .mobile-table tbody td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        text-align: left !important;
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
    
    /* Add labels to table cells on mobile */
    .mobile-table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        display: block;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.25rem;
    }
    
    /* Style the actual data */
    .mobile-table tbody td > * {
        font-size: 0.9rem;
        font-weight: 500;
    }
    
    /* Action buttons in mobile table cards */
    .mobile-table tbody td .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
        margin-top: 0.5rem;
    }
    
    .mobile-table tbody td .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.75rem;
        flex: 1;
        min-width: auto;
    }
    
    /* Compact table for lists that should stay tabular */
    .table-compact-mobile {
        font-size: 0.8rem;
    }
    
    .table-compact-mobile th,
    .table-compact-mobile td {
        padding: 0.375rem 0.25rem;
        font-size: 0.75rem;
        line-height: 1.2;
    }
    
    .table-compact-mobile .btn {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        border-radius: 4px;
    }
    
    /* Horizontal scroll tables for data that must stay tabular */
    .table-scroll-mobile {
        min-width: 600px;
        font-size: 0.8rem;
    }
    
    .table-scroll-mobile th,
    .table-scroll-mobile td {
        white-space: nowrap;
        padding: 0.5rem 0.375rem;
        min-width: 80px;
    }
    
    /* Priority columns - always show these */
    .table .priority-high {
        min-width: 120px !important;
    }
    
    .table .priority-medium {
        min-width: 100px !important;
    }
    
    .table .priority-low {
        min-width: 80px !important;
    }
    
    /* Hide less important columns on small screens */
    .table .hide-mobile {
        display: none !important;
    }
    
    /* Show mobile-only columns */
    .table .show-mobile {
        display: table-cell !important;
    }
}

/* Tablet adjustments (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .table {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
    }
    
    .table .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.5rem;
    }
    
    /* Hide some columns on tablet */
    .table .hide-tablet {
        display: none !important;
    }
}

/* Large mobile/small tablet specific */
@media (min-width: 576px) and (max-width: 767px) {
    .mobile-table tbody tr {
        padding: 1.25rem;
    }
    
    .mobile-table tbody td .btn-group .btn {
        min-width: 100px;
    }
}

/* Extra small mobile */
@media (max-width: 575px) {
    .mobile-table tbody tr {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .mobile-table tbody td:before {
        font-size: 0.7rem;
    }
    
    .mobile-table tbody td > * {
        font-size: 0.85rem;
    }
    
    .table-responsive {
        margin: 0 -0.5rem;
        border-radius: 8px;
    }
}

/* Touch enhancements for mobile table interactions */
@media (pointer: coarse) {
    .table .btn,
    .table .nav-link,
    .table .dropdown-toggle {
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .table .dropdown-menu {
        min-width: 150px;
    }
    
    .table .dropdown-item {
        padding: 0.5rem 1rem;
        min-height: 40px;
        display: flex;
        align-items: center;
    }
}

/* Status badges mobile optimization */
@media (max-width: 767px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
        border-radius: 6px;
    }
    
    .mobile-table .badge {
        display: inline-block;
        margin-top: 0.25rem;
    }
}

/* Pagination mobile improvements */
@media (max-width: 767px) {
    .pagination {
        justify-content: center;
        margin-top: 1rem;
    }
    
    .pagination .page-link {
        padding: 0.5rem 0.75rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hide page numbers on very small screens, keep prev/next */
    .pagination .page-item:not(.prev):not(.next) .page-link {
        display: none;
    }
    
    .pagination .page-item.active .page-link,
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link {
        display: flex;
    }
}

/* Filter and search mobile improvements */
@media (max-width: 767px) {
    .table-filters {
        flex-direction: column;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .table-filters .form-control,
    .table-filters .form-select {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .table-search {
        position: relative;
        margin-bottom: 1rem;
    }
    
    .table-search .form-control {
        padding-right: 45px;
    }
    
    .table-search .btn {
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        border: none;
        background: transparent;
        padding: 0.375rem;
    }
}