/* =================================
   Tables — single source of truth
   ================================= */

/* Elevated container — wrap any .data-table in one of these.
   All three names are aliases so existing markup keeps working. */
.table-wrap,
.table-container,
.table-responsive {
    background: var(--color-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* The one table component. Header = uppercase small-caps + bottom rule;
   rows = bottom border only + zebra + terracotta hover. */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    color: var(--color-text);
}

.data-table th {
    background: var(--light-color);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.015); }
.data-table tbody tr:hover { background: rgba(var(--primary-rgb), 0.05); }
.data-table tbody tr.selected { background: rgba(var(--primary-rgb), 0.1); }

/* Sortable header links */
.data-table th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}
.data-table th a:hover,
.data-table th.sort-active a { color: var(--primary-color); }

/* Cell helpers (both legacy and new names supported) */
.data-table .checkbox-cell,
.data-table .checkbox-col { width: 40px; text-align: center; }
.data-table .actions-cell,
.data-table .actions { white-space: nowrap; }
.data-table .num,
.data-table td.text-right,
.data-table th.text-right { text-align: right; font-variant-numeric: tabular-nums; }

/* =================================
   Sortable Headers
   ================================= */

.sortable-header a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.sortable-header a:hover {
    color: var(--primary-color);
}

.sortable-header.sort-active a {
    color: var(--primary-color);
    font-weight: 700;
}

.sort-indicator {
    font-size: 0.75rem;
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.sort-active .sort-indicator {
    opacity: 1;
}

/* =================================
   Sort Bar (for card-based lists)
   ================================= */

.sort-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

.sort-bar .sort-option {
    color: var(--secondary-color);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.sort-bar .sort-option:hover {
    color: var(--primary-color);
    background: var(--light-color);
}

.sort-bar .sort-option.active {
    color: var(--primary-color);
    font-weight: 600;
    background: var(--light-color);
}

.sort-bar .sort-separator {
    color: var(--border-color);
    user-select: none;
}

/* =================================
   Badges and indicators
   ================================= */

.transport-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* =================================
   Text alignment utilities
   ================================= */

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* =================================
   Special row styles
   ================================= */

.font-bold {
    font-weight: bold;
}

.bg-gray-100 {
    background-color: var(--light-color);
}

/* =================================
   Responsive
   ================================= */

@media screen and (max-width: 768px) {
    /* Wrappers already scroll horizontally (overflow-x:auto), so wide
       tables stay reachable on narrow screens. */
    .sort-bar {
        flex-wrap: wrap;
    }
}
