/**
 * Enterprise HRM ERP System - Excel-like Table Styles
 */

/* Table Container */
.table-container {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.table-header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
    gap: 16px;
}

.table-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.table-actions {
    display: flex;
    gap: 10px;
}

/* Excel-like Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background-color: var(--white);
}

.data-table thead {
    background-color: #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
}

.data-table th:last-child {
    border-right: none;
}

.data-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 25px;
}

.data-table th.sortable:hover {
    background-color: #e2e8f0;
}

.data-table th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    font-size: 12px;
    opacity: 0.5;
}

.data-table th.sort-asc::after {
    content: '↑';
    opacity: 1;
}

.data-table th.sort-desc::after {
    content: '↓';
    opacity: 1;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tbody tr.selected {
    background-color: #dbeafe;
}

.data-table td {
    padding: 10px;
    border-right: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table td:last-child {
    border-right: none;
}

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

/* Table Actions Column */
.table-actions-cell {
    width: 120px;
    text-align: center;
    white-space: nowrap;
}

.table-actions-cell .btn {
    margin: 0 2px;
    padding: 4px 8px;
    font-size: 11px;
}

/* Table Footer (Pagination) */
.table-footer {
    padding: 20px 28px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
    gap: 16px;
}

.table-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    gap: 5px;
    align-items: center;
}

.pagination .btn {
    padding: 6px 12px;
    font-size: 12px;
    min-width: 35px;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    margin: 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Table Filters */
.table-filters {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8fafc;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.filter-group .form-control {
    padding: 6px 10px;
    font-size: 13px;
}

/* Empty State */
.table-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.table-empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.table-empty-message {
    font-size: 16px;
    margin-bottom: 10px;
}

.table-empty-submessage {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Table Scroll Wrapper for Horizontal Scrolling */
.table-scroll-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    position: relative;
    width: 100%;
    margin: 0;
}

.table-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Table */
@media (max-width: 1024px) {
    .table-scroll-wrapper {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 900px;
    }
}

@media (max-width: 768px) {
    .table-container {
        overflow: visible;
    }
    
    .table-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 800px;
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 20px;
    }
    
    .table-filters {
        flex-direction: column;
        padding: 20px;
    }
    
    .filter-group {
        width: 100%;
        min-width: 100%;
    }
    
    .table-actions-cell {
        width: auto;
        min-width: 150px;
    }
    
    .table-actions-cell .btn {
        padding: 4px 6px;
        font-size: 10px;
        margin: 2px 1px;
    }
}

@media (max-width: 480px) {
    .data-table {
        min-width: 700px;
        font-size: 11px;
    }
    
    .data-table th,
    .data-table td {
        padding: 6px 4px;
        font-size: 11px;
    }
    
    .table-header {
        padding: 15px;
    }
    
    .table-filters {
        padding: 15px;
    }
    
    .table-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 15px;
    }
    
    .pagination {
        justify-content: center;
    }
}

/* Loading State */
.table-loading {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.table-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

