/**
 * Admin Table Components
 * 
 * Data tables, log viewers, and tabular data display
 * Optimized for readability and data density
 */

/* Base Table Wrapper */
.admin-table-wrapper {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.admin-table-wrapper__header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-table-wrapper__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.admin-table-wrapper__actions {
    display: flex;
    gap: var(--space-sm);
}

/* Base Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid oklch(from var(--border) l c h / 0.5);
}

.admin-table th {
    background: oklch(from var(--bg-alt) calc(l + 0.02) c h);
    font-weight: 600;
    color: var(--text);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 1;
}

.admin-table td {
    color: var(--text);
    vertical-align: top;
}

.admin-table tbody tr:hover {
    background: oklch(from var(--bg-alt) calc(l + 0.01) c h);
}

/* Table Variants */
.admin-table--striped tbody tr:nth-child(even) {
    background: oklch(from var(--bg) calc(l + 0.01) c h);
}

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

.admin-table--compact th,
.admin-table--compact td {
    padding: var(--space-sm);
}

/* Status Columns */
.admin-table__status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table__status--success {
    background: var(--success-subtle);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.admin-table__status--warning {
    background: var(--warning-subtle);
    color: var(--warning-border);
    border: 1px solid var(--warning-border);
}

.admin-table__status--error {
    background: var(--error-subtle);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

.admin-table__status--info {
    background: oklch(var(--l-subtle) var(--c-muted) var(--h-info));
    color: oklch(var(--l-text) var(--c-subtle) var(--h-info));
    border: 1px solid oklch(var(--l-border) var(--c-moderate) var(--h-info));
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator--success {
    background: var(--success);
}

.status-indicator--warning {
    background: var(--warning);
}

.status-indicator--error {
    background: var(--error);
}

.status-indicator--info {
    background: var(--info-base);
}

/* Action Columns */
.admin-table__actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.admin-table__action {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    transition: all var(--duration-default) var(--easing-default);
}

.admin-table__action:hover {
    background: oklch(from var(--accent) l c h / 0.1);
    text-decoration: none;
}

.admin-table__action--danger {
    color: var(--error);
}

.admin-table__action--danger:hover {
    background: oklch(from var(--error) l c h / 0.1);
}

/* Code/Log Columns */
.admin-table__code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.75rem;
    background: oklch(from var(--bg) calc(l + 0.02) c h);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Timestamp Columns */
.admin-table__timestamp {
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Scrollable Tables */
.admin-table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
}

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

.admin-table-scroll::-webkit-scrollbar-track {
    background: var(--bg);
}

.admin-table-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.admin-table-scroll::-webkit-scrollbar-thumb:hover {
    background: oklch(from var(--border) calc(l + 0.1) c h);
}

/* Empty State */
.admin-table__empty {
    text-align: center;
    padding: var(--space-lg);
    color: var(--muted);
}

.admin-table__empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* Loading State */
.admin-table--loading {
    position: relative;
    overflow: hidden;
}

.admin-table--loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    height: 100%;
    width: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        oklch(from var(--accent) l c h / 0.1),
        transparent
    );
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    100% {
        left: 100%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .admin-table-wrapper__header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    .admin-table-wrapper__actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .admin-table th,
    .admin-table td {
        padding: var(--space-sm);
    }
    
    .admin-table__actions {
        flex-direction: column;
        align-items: flex-start;
    }
}