/* Tables
   Tables, sorting, table actions */

/* ======= TABLE STYLES - Compact POS/ERP Style ======= */

.table-container {
    background-color: var(--card-bg-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
    font-size: 0.875rem;
}

    .table th,
    .table td {
        padding: 0.5rem 0.75rem;
        text-align: var(--text-align-start);
        vertical-align: middle;
        border-bottom: 1px solid #e5e7eb;
    }

    .table thead th {
        background-color: #f9fafb;
        color: #374151;
        font-weight: 600;
        border-bottom: 1px solid #e5e7eb;
        white-space: nowrap;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
        position: relative;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }

        .table thead th:first-child {
            border-top-left-radius: var(--border-radius-md);
        }

        .table thead th:last-child {
            border-top-right-radius: var(--border-radius-md);
        }

html[dir="rtl"] .table thead th:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: var(--border-radius-md);
}

html[dir="rtl"] .table thead th:last-child {
    border-top-right-radius: 0;
    border-top-left-radius: var(--border-radius-md);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

    .table tbody tr:last-child td:first-child {
        border-bottom-left-radius: var(--border-radius-md);
    }

    .table tbody tr:last-child td:last-child {
        border-bottom-right-radius: var(--border-radius-md);
    }

html[dir="rtl"] .table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: var(--border-radius-md);
}

html[dir="rtl"] .table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: var(--border-radius-md);
}

.table-responsive {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* Products page: fill content area; only the list scrolls */
.products-page-root {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.products-page-card {
    flex: 1 1 0;
    overflow: hidden;
}

.products-page-card-body {
    overflow: hidden;
}

.products-list-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.table tbody tr {
    transition: background-color var(--transition-fast);
}

    .table tbody tr:hover {
        background-color: rgba(var(--primary-color-rgb), 0.03);
    }

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(var(--primary-color-rgb), 0.01);
}

    .table-striped tbody tr:nth-of-type(odd):hover {
        background-color: rgba(var(--primary-color-rgb), 0.05);
    }

/* Table actions */
.table-actions {
    text-align: end;
}

html[dir="rtl"] .table-actions {
    text-align: start;
}

/* Sortable tables */
.table-sort {
    position: relative;
    cursor: pointer;
    user-select: none;
}

    .table-sort::after {
        content: '↕';
        position: absolute;
        right: 0.5rem;
        color: rgba(255, 255, 255, 0.6);
        font-size: 0.8em;
    }

html[dir="rtl"] .table-sort::after {
    right: auto;
    left: 0.5rem;
}

.table-sort.asc::after {
    content: '↑';
    color: white;
}

.table-sort.desc::after {
    content: '↓';
    color: white;
}

/* Table Pagination and Controls */
.table-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--tertiary-color);
    border-top: 1px solid var(--border-color);
}

.table-length-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

    .table-length-control .form-select {
        width: auto;
        padding-right: 2rem;
    }

.table-info {
    color: var(--text-light);
    font-size: var(--font-size-sm);
}
