/*
 * Global Table Styles - Theme-Aware
 * Unified table styling with hover effects and zebra striping
 * Version: 1.0
 * Date: 2025-11-21
 */

/* ===== BASE TABLE STYLES ===== */
.ccs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--color-surface);
}

.ccs-table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
}

/* ===== TABLE HEADER ===== */
.ccs-table thead {
    background: var(--color-background-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.ccs-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.ccs-table th:first-child {
    border-top-left-radius: 0.5rem;
}

.ccs-table th:last-child {
    border-top-right-radius: 0.5rem;
}

/* ===== TABLE BODY ===== */
.ccs-table td {
    padding: 0.75rem 1rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

/* ===== ROW HOVER EFFECTS ===== */
.ccs-table tbody tr {
    transition: background-color 0.15s ease;
}

.ccs-table tbody tr:hover {
    background-color: var(--color-hover);
}

[data-theme="dark"] .ccs-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* ===== ZEBRA STRIPING ===== */
.ccs-table-striped tbody tr:nth-child(even) {
    background-color: var(--color-background-tertiary);
}

.ccs-table-striped tbody tr:nth-child(even):hover {
    background-color: var(--color-hover);
}

[data-theme="dark"] .ccs-table-striped tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ===== COMPACT TABLE ===== */
.ccs-table-compact th,
.ccs-table-compact td {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

/* ===== BORDERED TABLE ===== */
.ccs-table-bordered th,
.ccs-table-bordered td {
    border: 1px solid var(--color-border);
}

/* ===== SORTABLE HEADERS ===== */
.ccs-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.75rem;
}

.ccs-table th.sortable:hover {
    background-color: var(--color-hover);
}

.ccs-table th.sortable::after {
    content: '\f0dc'; /* FontAwesome sort icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.75rem;
}

.ccs-table th.sortable.sort-asc::after {
    content: '\f0de'; /* sort-up */
    opacity: 1;
    color: var(--color-primary);
}

.ccs-table th.sortable.sort-desc::after {
    content: '\f0dd'; /* sort-down */
    opacity: 1;
    color: var(--color-primary);
}

/* ===== CLICKABLE ROWS ===== */
.ccs-table-clickable tbody tr {
    cursor: pointer;
}

.ccs-table-clickable tbody tr:hover {
    background-color: var(--bg-info-light);
}

/* ===== STATUS CELLS ===== */
.ccs-table .cell-success {
    color: var(--color-success);
    font-weight: 500;
}

.ccs-table .cell-warning {
    color: var(--color-warning);
    font-weight: 500;
}

.ccs-table .cell-error {
    color: var(--color-error);
    font-weight: 500;
}

.ccs-table .cell-info {
    color: var(--color-info);
    font-weight: 500;
}

.ccs-table .cell-muted {
    color: var(--color-text-tertiary);
}

/* ===== NUMERIC CELLS ===== */
.ccs-table .cell-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

/* ===== BADGE IN TABLE ===== */
.ccs-table .table-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.ccs-table .table-badge-success {
    background: var(--bg-success-light);
    color: var(--color-success);
}

.ccs-table .table-badge-warning {
    background: var(--bg-warning-light);
    color: var(--color-warning-dark);
}

.ccs-table .table-badge-error {
    background: var(--bg-error-light);
    color: var(--color-error);
}

.ccs-table .table-badge-info {
    background: var(--bg-info-light);
    color: var(--color-info);
}

/* ===== EMPTY STATE ===== */
.ccs-table-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-tertiary);
}

.ccs-table-empty td {
    border-bottom: none;
}

/* ===== LOADING STATE ===== */
.ccs-table-loading {
    position: relative;
    min-height: 200px;
}

.ccs-table-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: table-spin 0.8s linear infinite;
}

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

/* ===== RESPONSIVE TABLE ===== */
@media (max-width: 768px) {
    .ccs-table-responsive {
        display: block;
    }

    .ccs-table-responsive thead {
        display: none;
    }

    .ccs-table-responsive tbody,
    .ccs-table-responsive tr,
    .ccs-table-responsive td {
        display: block;
        width: 100%;
    }

    .ccs-table-responsive tr {
        margin-bottom: 1rem;
        border: 1px solid var(--color-border);
        border-radius: 0.5rem;
        background: var(--color-surface);
    }

    .ccs-table-responsive td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid var(--color-border);
    }

    .ccs-table-responsive td:last-child {
        border-bottom: none;
    }

    .ccs-table-responsive td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--color-text-secondary);
    }
}

/* ===== TABLE ACTIONS ===== */
.ccs-table .table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.ccs-table .table-action-btn {
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ccs-table .table-action-btn:hover {
    background: var(--color-hover);
    color: var(--color-primary);
}

/* ===== TABLE FOOTER ===== */
.ccs-table tfoot {
    background: var(--color-background-secondary);
    font-weight: 600;
}

.ccs-table tfoot td {
    border-top: 2px solid var(--color-border);
    border-bottom: none;
}

/* ===== HIGHLIGHTED ROW ===== */
.ccs-table tr.row-highlighted {
    background-color: var(--bg-info-light) !important;
}

.ccs-table tr.row-success {
    background-color: var(--bg-success-light) !important;
}

.ccs-table tr.row-warning {
    background-color: var(--bg-warning-light) !important;
}

.ccs-table tr.row-error {
    background-color: var(--bg-error-light) !important;
}
