/* Table Components - Standardized table layouts */

/* Base table styles */
.table-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table td {
    padding: 12px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
    transition: background-color 0.2s ease;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Table variants */
.table-striped tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.table-striped tbody tr:nth-child(even):hover {
    background: var(--border-light);
}

.table-bordered {
    border: 1px solid var(--border-color);
}

.table-bordered th,
.table-bordered td {
    border: 1px solid var(--border-color);
}

.table-compact th,
.table-compact td {
    padding: 8px 12px;
}

.table-spacious th,
.table-spacious td {
    padding: 16px 20px;
}

/* Table cell alignment */
.table .text-center {
    text-align: center;
}

.table .text-right {
    text-align: right;
}

.table .text-nowrap {
    white-space: nowrap;
}

/* Status badges in tables */
.table .badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table .badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-success);
}

.table .badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
}

.table .badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
}

.table .badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--status-info);
}

.table .badge-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Action buttons in tables */
.table .table-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}

.table .table-actions .btn {
    padding: 6px 8px;
    font-size: 12px;
    min-width: auto;
}

/* Sortable table headers */
.table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 30px;
    user-select: none;
}

.table th.sortable:hover {
    background: var(--border-light);
}

.table th.sortable::after {
    content: '↕';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 12px;
}

.table th.sortable.asc::after {
    content: '↑';
    opacity: 1;
    color: var(--accent-primary);
}

.table th.sortable.desc::after {
    content: '↓';
    opacity: 1;
    color: var(--accent-primary);
}

/* Empty state */
.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.table-empty i {
    font-size: 48px;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 16px;
    display: block;
}

.table-empty h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}

.table-empty p {
    font-size: 14px;
    color: var(--text-muted, #9ca3af);
    margin: 0 0 16px 0;
}

/* Loading state */
.table-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Table summary/footer */
.table-footer {
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.table-footer .table-info {
    display: flex;
    gap: 16px;
}

.table-footer .table-actions {
    display: flex;
    gap: 8px;
}

/* Responsive tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-container {
        margin: 0 -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .table th,
    .table td {
        padding: 8px 12px;
        font-size: 13px;
    }

    .table .table-actions {
        flex-direction: column;
        gap: 2px;
    }

    .table .table-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 11px;
        padding: 4px 6px;
    }

    /* Stack table for mobile */
    .table-stack {
        border: none;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tbody tr {
        display: block;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 16px;
    }

    .table-stack tbody td {
        display: block;
        padding: 4px 0;
        border: none;
        text-align: left !important;
    }

    .table-stack tbody td::before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: var(--text-secondary);
        display: inline-block;
        min-width: 100px;
    }

    .table-footer {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .table-footer .table-info {
        flex-direction: column;
        gap: 8px;
    }
}

/* Data table specific styles */
.data-table {
    @extend .table;
}

.data-table .currency {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-align: right;
}

.data-table .number {
    font-family: 'Courier New', monospace;
    text-align: right;
}

.data-table .date {
    white-space: nowrap;
    color: var(--text-secondary);
}

.data-table .status {
    text-transform: capitalize;
}

/* Inventory specific table styles */
.inventory-table .stock-level {
    font-weight: 600;
}

.inventory-table .stock-level.low {
    color: var(--status-warning);
}

.inventory-table .stock-level.out {
    color: var(--status-danger);
}

.inventory-table .stock-level.good {
    color: var(--status-success);
}

/* Order table styles */
.order-table .order-id {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--accent-primary);
}

.order-table .order-total {
    font-weight: 700;
    color: var(--text-primary);
}