/*
 * Tables of the cost report pages (App\Filament\Pages\Costs and
 * CostsForProject).
 *
 * The panel ships Filament's own compiled stylesheet and the project has no
 * Tailwind build of its own, so utility classes in these Blade views would not
 * exist in the delivered CSS. The tables are therefore styled here as plain
 * CSS against Filament's theme variables, the same way provider-picker.css
 * does it for the custom form field.
 */

.fi-cost-table-wrapper {
    /* Let a wide table scroll inside the section instead of stretching the
       page; the negative margin lets the rows' padding line up with the
       section's own padding while the scroll area still spans its full width. */
    margin-inline: -1rem;
    overflow-x: auto;
}

.fi-cost-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    line-height: 1.25rem;
    text-align: left;
}

.fi-cost-table th,
.fi-cost-table td {
    padding: 0.625rem 1rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* The header is a quiet label row, not a heavy band. */
.fi-cost-table thead th {
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    color: var(--gray-500, #6b7280);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.fi-cost-table tbody tr + tr {
    border-top: 1px solid var(--gray-100, #f3f4f6);
}

.fi-cost-table tbody tr {
    transition: background-color 0.1s ease;
}

.fi-cost-table tbody tr:hover {
    background: var(--gray-50, #f9fafb);
}

.fi-cost-table td {
    color: var(--gray-950, #030712);
}

/* Numbers line up column-wise and never wrap mid-figure. */
.fi-cost-table .fi-cost-num {
    font-variant-numeric: tabular-nums;
}

.fi-cost-table .fi-cost-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.fi-cost-table .fi-cost-muted {
    color: var(--gray-500, #6b7280);
}

.fi-cost-table .fi-cost-model {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
}

.fi-cost-table .fi-cost-name {
    font-weight: 500;
}

/* The project name links through to that project's cost detail page. */
.fi-cost-table a.fi-cost-link {
    color: var(--primary-600, #4f46e5);
    font-weight: 500;
    text-decoration: none;
}

.fi-cost-table a.fi-cost-link:hover {
    text-decoration: underline;
}

/* Share column: a proportion bar plus its percentage. The column is the widest
   one, so it may wrap out of the nowrap rule above. */
.fi-cost-table .fi-cost-share-cell {
    width: 30%;
    min-width: 12rem;
    white-space: normal;
}

.fi-cost-share {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fi-cost-share-track {
    flex: 1 1 auto;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--gray-100, #f3f4f6);
    overflow: hidden;
}

.fi-cost-share-fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--primary-500, #6366f1);
}

.fi-cost-share-value {
    flex: 0 0 auto;
    width: 3.5rem;
    color: var(--gray-500, #6b7280);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* The status badge brings its own line-height; keep the row compact. */
.fi-cost-table td .fi-badge {
    vertical-align: middle;
}

/*
 * Breakdown lists (cost per provider / per model) on the detail page — the
 * same proportion bar in a stacked, two-line layout, side by side on wide
 * screens and stacked on narrow ones.
 */

.fi-cost-breakdown-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .fi-cost-breakdown-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.fi-cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.fi-cost-breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.fi-cost-breakdown-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.fi-cost-breakdown-label {
    overflow: hidden;
    color: var(--gray-950, #030712);
    font-size: 0.875rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fi-cost-breakdown-label.fi-cost-model {
    font-weight: 400;
}

.fi-cost-breakdown-amount {
    flex: 0 0 auto;
    color: var(--gray-950, #030712);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.fi-cost-breakdown-meta {
    flex: 0 0 auto;
    width: 7rem;
    overflow: hidden;
    color: var(--gray-500, #6b7280);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty-state copy shared by every section on the two pages. */
.fi-cost-empty {
    color: var(--gray-500, #6b7280);
    font-size: 0.875rem;
}

/* --- Dark mode ---------------------------------------------------------- */

.dark .fi-cost-table thead th {
    border-bottom-color: var(--gray-700, #374151);
    color: var(--gray-400, #9ca3af);
}

.dark .fi-cost-table tbody tr + tr {
    border-top-color: var(--gray-800, #1f2937);
}

.dark .fi-cost-table tbody tr:hover {
    background: var(--gray-800, #1f2937);
}

.dark .fi-cost-table td {
    color: var(--white, #fff);
}

.dark .fi-cost-table .fi-cost-muted,
.dark .fi-cost-share-value,
.dark .fi-cost-breakdown-meta,
.dark .fi-cost-empty {
    color: var(--gray-400, #9ca3af);
}

.dark .fi-cost-table a.fi-cost-link {
    color: var(--primary-400, #818cf8);
}

.dark .fi-cost-share-track,
.dark .fi-cost-breakdown-track {
    background: var(--gray-700, #374151);
}

.dark .fi-cost-breakdown-label,
.dark .fi-cost-breakdown-amount {
    color: var(--white, #fff);
}
