/* ============================================================================
   Data Tables Component
   Unified table styling for list views and reports
   ============================================================================ */

/* Table Container Card */
.data-table-card {
    background: white;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.data-table-card .data-table {
    margin-bottom: 0;
}

/* Base Data Table */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

/* Table Header */
.data-table thead th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 2px solid var(--gray-200);
    text-align: left;
    white-space: nowrap;
}

.data-table thead th:first-child {
    padding-left: 1.5rem;
}

.data-table thead th:last-child {
    padding-right: 1.5rem;
}

/* Table Body */
.data-table tbody tr {
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--gray-100);
}

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

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

.data-table tbody td {
    padding: 1rem;
    vertical-align: middle;
    color: var(--gray-700);
}

.data-table tbody td:first-child {
    padding-left: 1.5rem;
}

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

/* Row Variants */
.data-table tbody tr.unmarked {
    background: var(--status-warning-light);
    border-left: 4px solid var(--status-warning);
}

.data-table tbody tr.unmarked:hover {
    background: #fde68a;
}

.data-table tbody tr.success-row {
    background: var(--status-success-light);
}

.data-table tbody tr.danger-row {
    background: var(--status-danger-light);
}

.data-table tbody tr.selected {
    background: #dbeafe;
    border-left: 4px solid var(--status-info);
}

/* Striped Table */
.data-table--striped tbody tr:nth-child(even) {
    background: var(--gray-50);
}

.data-table--striped tbody tr:nth-child(even):hover {
    background: #f0fdf4;
}

/* Compact Table */
.data-table--compact thead th,
.data-table--compact tbody td {
    padding: 0.75rem;
}

.data-table--compact thead th:first-child,
.data-table--compact tbody td:first-child {
    padding-left: 1rem;
}

.data-table--compact thead th:last-child,
.data-table--compact tbody td:last-child {
    padding-right: 1rem;
}

/* Bordered Table */
.data-table--bordered {
    border: 1px solid var(--gray-200);
}

.data-table--bordered th,
.data-table--bordered td {
    border: 1px solid var(--gray-200);
}

/* Student Row (with avatar) - only apply flex to non-table elements */
.data-table .student-row-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Legacy support for divs with student-row class */
div.student-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.student-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    object-fit: cover;
    border: 2px solid var(--gray-200);
}

.student-info {
    display: flex;
    flex-direction: column;
}

.student-name {
    font-weight: 600;
    color: var(--gray-800);
}

.student-ic {
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Actions Column */
.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.table-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.875rem;
}

.table-action-btn--view {
    background: var(--status-info-light);
    color: var(--status-info);
}

.table-action-btn--view:hover {
    background: var(--status-info);
    color: white;
}

.table-action-btn--edit {
    background: var(--status-warning-light);
    color: var(--status-warning-text);
}

.table-action-btn--edit:hover {
    background: var(--status-warning);
    color: white;
}

.table-action-btn--delete {
    background: var(--status-danger-light);
    color: var(--status-danger);
}

.table-action-btn--delete:hover {
    background: var(--status-danger);
    color: white;
}

/* Summary Row */
.data-table tfoot tr {
    background: var(--gray-100);
    font-weight: 700;
}

.data-table tfoot td {
    padding: 1rem;
    border-top: 2px solid var(--gray-300);
}

/* Amount Column */
.amount-cell {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    text-align: right;
}

.amount-cell--positive {
    color: var(--status-success-text);
}

.amount-cell--negative {
    color: var(--status-danger);
}

/* Date Column */
.date-cell {
    white-space: nowrap;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Responsive Table Wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Card View (alternative to table) */
@media (max-width: 768px) {
    .data-table--mobile-cards {
        display: block;
    }

    .data-table--mobile-cards thead {
        display: none;
    }

    .data-table--mobile-cards tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .data-table--mobile-cards tbody tr {
        display: flex;
        flex-direction: column;
        background: white;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-lg);
        padding: 1rem;
    }

    .data-table--mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--gray-100);
    }

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

    .data-table--mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600);
        text-transform: uppercase;
        font-size: 0.75rem;
    }
}

/* Table with Fixed Header */
.table-fixed-header {
    max-height: 500px;
    overflow-y: auto;
}

.table-fixed-header thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--gray-50);
}
