/* =========================================
   Modern Table Styles for SIMLAB
   Version: 1.0
   Date: 2026-07-26
   ========================================= */

/* Variables for easy customization */
:root {
    --table-border-radius: 12px;
    --table-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    --table-hover-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
    --table-header-bg: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    --table-row-hover: linear-gradient(90deg, rgba(37, 99, 235, 0.04), rgba(96, 165, 250, 0.03));
    --table-border-color: rgba(226, 232, 240, 0.8);
    --table-text: #0f172a;
    --table-text-muted: #64748b;
}

/* =========================================
   Modern Table Container
   ========================================= */

.modern-table-wrapper {
    background: white;
    border-radius: var(--table-border-radius);
    box-shadow: var(--table-shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modern-table-wrapper:hover {
    box-shadow: var(--table-hover-shadow);
    transform: translateY(-2px);
}

/* Table responsive wrapper with custom scrollbar */
.table-responsive {
    border-radius: var(--table-border-radius);
    overflow-x: auto;
    overflow-y: visible;
}

/* Custom Scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #94a3b8, #cbd5e1);
    border-radius: 4px;
    transition: background 0.3s;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #64748b, #94a3b8);
}

/* =========================================
   Modern Table Base Styles
   ========================================= */

.table-modern {
    margin-bottom: 0;
    width: 100%;
    color: var(--table-text);
    border-collapse: separate;
    border-spacing: 0;
}

/* =========================================
   Table Header
   ========================================= */

.table-modern thead th {
    background: var(--table-header-bg);
    color: var(--table-text);
    font-weight: 700;
    font-size: 0.8125rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 1rem 1.25rem;
    border-bottom: 2px solid var(--table-border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    transition: all 0.2s ease;
}

.table-modern thead th:first-child {
    border-top-left-radius: var(--table-border-radius);
    padding-left: 1.5rem;
}

.table-modern thead th:last-child {
    border-top-right-radius: var(--table-border-radius);
    padding-right: 1.5rem;
}

/* Sortable columns */
.table-modern thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table-modern thead th.sortable:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%);
}

.table-modern thead th.sortable::after {
    content: '\2195';
    margin-left: 0.5rem;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.table-modern thead th.sortable:hover::after {
    opacity: 0.7;
}

.table-modern thead th.sorted-asc::after {
    content: '\2191';
    opacity: 1;
    color: #2563eb;
}

.table-modern thead th.sorted-desc::after {
    content: '\2193';
    opacity: 1;
    color: #2563eb;
}

/* =========================================
   Table Body
   ========================================= */

.table-modern tbody tr {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid var(--table-border-color);
}

.table-modern tbody tr:last-child {
    border-bottom: none;
}

.table-modern tbody tr:hover {
    background: var(--table-row-hover);
    transform: scale(1.005);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.table-modern tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    font-size: 0.9375rem;
    color: var(--table-text);
    transition: all 0.2s ease;
}

.table-modern tbody td:first-child {
    padding-left: 1.5rem;
    font-weight: 600;
}

.table-modern tbody td:last-child {
    padding-right: 1.5rem;
}

/* Alternate row colors */
.table-modern.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(248, 250, 252, 0.5);
}

/* =========================================
   Table Variants
   ========================================= */

/* Compact Table */
.table-modern.table-sm thead th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
}

.table-modern.table-sm tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}

/* Bordered Table */
.table-modern.table-bordered {
    border: 1px solid var(--table-border-color);
}

.table-modern.table-bordered th,
.table-modern.table-bordered td {
    border: 1px solid var(--table-border-color);
}

/* Borderless Table */
.table-modern.table-borderless thead th,
.table-modern.table-borderless tbody td {
    border: none;
}

/* =========================================
   Status Badges in Tables
   ========================================= */

.table-modern .badge {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.025em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.table-modern .badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Badge color variants */
.table-modern .badge.bg-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
}

.table-modern .badge.bg-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
}

.table-modern .badge.bg-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: white;
}

.table-modern .badge.bg-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
}

.table-modern .badge.bg-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
}

.table-modern .badge.bg-secondary {
    background: linear-gradient(135deg, #6b7280, #4b5563) !important;
}

/* Subtle badge variants */
.table-modern .badge.bg-success-subtle {
    background: rgba(16, 185, 129, 0.1) !important;
    color: #059669;
    box-shadow: none;
}

.table-modern .badge.bg-danger-subtle {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #dc2626;
    box-shadow: none;
}

.table-modern .badge.bg-warning-subtle {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #d97706;
    box-shadow: none;
}

.table-modern .badge.bg-info-subtle {
    background: rgba(59, 130, 246, 0.1) !important;
    color: #2563eb;
    box-shadow: none;
}

.table-modern .badge.bg-primary-subtle {
    background: rgba(37, 99, 235, 0.1) !important;
    color: #1d4ed8;
    box-shadow: none;
}

.table-modern .badge.bg-secondary-subtle {
    background: rgba(107, 114, 128, 0.1) !important;
    color: #4b5563;
    box-shadow: none;
}

/* =========================================
   Action Buttons in Tables
   ========================================= */

.table-modern .btn-group {
    display: flex;
    gap: 0.375rem;
    flex-wrap: nowrap;
}

.table-modern .btn-sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.table-modern .btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.table-modern .btn-sm:active {
    transform: translateY(0);
}

/* Button color variants */
.table-modern .btn-outline-primary {
    color: #2563eb;
    border: 1.5px solid #2563eb;
    background: rgba(37, 99, 235, 0.05);
}

.table-modern .btn-outline-primary:hover {
    background: #2563eb;
    color: white;
}

.table-modern .btn-outline-warning {
    color: #f59e0b;
    border: 1.5px solid #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.table-modern .btn-outline-warning:hover {
    background: #f59e0b;
    color: white;
}

.table-modern .btn-outline-success {
    color: #10b981;
    border: 1.5px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.table-modern .btn-outline-success:hover {
    background: #10b981;
    color: white;
}

.table-modern .btn-outline-danger {
    color: #ef4444;
    border: 1.5px solid #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.table-modern .btn-outline-danger:hover {
    background: #ef4444;
    color: white;
}

.table-modern .btn-outline-info {
    color: #3b82f6;
    border: 1.5px solid #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

.table-modern .btn-outline-info:hover {
    background: #3b82f6;
    color: white;
}

/* =========================================
   Table Pagination
   ========================================= */

.pagination-modern {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding: 1rem;
    flex-wrap: wrap;
}

.pagination-modern .page-link {
    border-radius: 8px;
    padding: 0.5rem 0.875rem;
    border: 1.5px solid var(--table-border-color);
    color: var(--table-text);
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.pagination-modern .page-link:hover {
    background: var(--table-row-hover);
    border-color: #2563eb;
    color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.pagination-modern .page-item.active .page-link {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pagination-modern .page-item.disabled .page-link {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================================
   Table Info & Search
   ========================================= */

.table-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--table-border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.table-search {
    position: relative;
    max-width: 320px;
    flex: 1;
    min-width: 200px;
}

.table-search input {
    padding: 0.65rem 1rem 0.65rem 2.75rem;
    border-radius: 10px;
    border: 1.5px solid var(--table-border-color);
    width: 100%;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
}

.table-search input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.table-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--table-text-muted);
    font-size: 1rem;
}

.table-info-text {
    color: var(--table-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

/* =========================================
   Empty State
   ========================================= */

.table-empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--table-text-muted);
}

.table-empty-state i {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1.5rem;
}

.table-empty-state h4 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--table-text);
}

.table-empty-state p {
    font-size: 0.9375rem;
    margin-bottom: 0;
}

/* =========================================
   Loading State
   ========================================= */

.table-loading {
    position: relative;
    min-height: 200px;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--table-border-color);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* =========================================
   Responsive Behavior
   ========================================= */

@media (max-width: 768px) {
    .modern-table-wrapper {
        border-radius: 8px;
    }
    
    .table-modern thead th,
    .table-modern tbody td {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .table-modern thead th:first-child,
    .table-modern tbody td:first-child {
        padding-left: 1rem;
    }
    
    .table-modern thead th:last-child,
    .table-modern tbody td:last-child {
        padding-right: 1rem;
    }
    
    .table-header-actions {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
    
    .table-search {
        max-width: 100%;
    }
    
    .pagination-modern {
        padding: 0.75rem;
        gap: 0.375rem;
    }
    
    .pagination-modern .page-link {
        padding: 0.375rem 0.625rem;
        font-size: 0.875rem;
    }
}

/* =========================================
   DataTables Integration
   ========================================= */

/* Hide default DataTables elements */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    display: none !important;
}

/* DataTable processing indicator */
.dataTables_processing {
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 12px !important;
    padding: 1.5rem 2rem !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important;
    border: none !important;
}

/* =========================================
   Print Styles
   ========================================= */

@media print {
    .modern-table-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .table-modern tbody tr:hover {
        background: none;
        transform: none;
        box-shadow: none;
    }
    
    .table-modern .btn-group,
    .table-header-actions,
    .pagination-modern {
        display: none !important;
    }
}

/* =========================================
   Dark Mode Support (Optional)
   ========================================= */

@media (prefers-color-scheme: dark) {
    :root {
        --table-border-color: rgba(71, 85, 105, 0.3);
        --table-text: #e2e8f0;
        --table-text-muted: #94a3b8;
        --table-header-bg: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        --table-row-hover: linear-gradient(90deg, rgba(59, 130, 246, 0.1), rgba(96, 165, 250, 0.08));
    }
    
    .modern-table-wrapper {
        background: #1e293b;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #0f172a;
    }
    
    .table-modern tbody tr {
        border-bottom-color: rgba(71, 85, 105, 0.3);
    }
    
    .table-search input {
        background: #0f172a;
        color: #e2e8f0;
        border-color: rgba(71, 85, 105, 0.3);
    }
}
