/*
====================================================
DoseClock Tables
Package 3
Readable clinical table styling
====================================================
*/

.table-wrapper,
.responsive-table,
.table-responsive,
.stock-table-wrapper,
.admin-log-table-wrapper,
.audit-table-wrapper,
.report-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

table,
.table,
.stock-table,
.admin-log-table,
.audit-table,
.report-table,
.medication-table,
.users-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    background: #ffffff;
    color: var(--color-text);
}

caption {
    caption-side: top;
    padding: 0.9rem 1rem;
    color: var(--color-heading);
    font-weight: 700;
    text-align: left;
}

thead,
.table thead {
    background: #eef4ff;
}

th,
td,
.table th,
.table td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border);
}

th,
.table th {
    color: var(--color-heading);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #f8fbff;
}

td.numeric,
th.numeric,
.table-cell--number,
.table-heading--number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

td.actions,
th.actions,
.table-cell--actions,
.table-heading--actions {
    text-align: right;
    white-space: nowrap;
}

.table-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.status-badge,
.table-status,
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.25rem 0.65rem;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
}

.status-badge--success,
.table-status--success,
.badge-status--success {
    background: #dcfce7;
    color: #14532d;
}

.status-badge--warning,
.table-status--warning,
.badge-status--warning {
    background: #fef3c7;
    color: #78350f;
}

.status-badge--danger,
.table-status--danger,
.badge-status--danger {
    background: #fee2e2;
    color: #7f1d1d;
}

.status-badge--info,
.table-status--info,
.badge-status--info {
    background: #dbeafe;
    color: #1e3a8a;
}

.stock-low,
.stock-danger,
.table-row--danger {
    background: #fff7f7;
}

.stock-warning,
.table-row--warning {
    background: #fffdf0;
}

.stock-ok,
.table-row--success {
    background: #f6fff8;
}

.medication-table .medication-name,
.stock-table .medication-name,
.admin-log-table .medication-name {
    font-weight: 700;
    color: var(--color-heading);
}

.table-muted,
.cell-muted {
    color: var(--color-muted);
}

.table-date,
.table-time,
.cell-date,
.cell-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-note,
.cell-note {
    max-width: 34rem;
}

@media (max-width: 768px) {
    .table-wrapper,
    .responsive-table,
    .table-responsive,
    .stock-table-wrapper,
    .admin-log-table-wrapper,
    .audit-table-wrapper,
    .report-table-wrapper {
        border-radius: var(--radius-md);
    }

    th,
    td,
    .table th,
    .table td {
        padding: 0.75rem;
    }

    caption {
        padding: 0.75rem;
    }

    td.actions,
    th.actions,
    .table-cell--actions,
    .table-heading--actions {
        text-align: left;
    }

    .table-actions {
        justify-content: flex-start;
    }
}
