/* Billing (Components/Pages/Billing/Billing.razor): the amount to pay, the filter and the invoices, a table on wider
   screens and one card per invoice on phones. The page frame and head are the shared app page ones (WebbuilderUI
   css/app-page.css). Skeleton: Components/Skeletons/Billing/BillingSkeleton.razor. */

/* ===========
     summary
   =========== */

.bil-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 520px;
    margin-bottom: 20px;
    padding: 18px 20px;
    border: 1px solid var(--app-line);
    border-radius: 20px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-soft);
}

.bil-summary-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--app-success-soft);
    font-size: 24px;
    color: var(--app-success);
}

.bil-summary-due .bil-summary-icon {
    background: var(--app-warning-soft);
    color: var(--app-warning);
}

.bil-summary-text {
    min-width: 0;
}

.bil-summary-label,
.bil-summary-note {
    margin: 0;
    font-size: 13px;
    color: var(--app-text-muted);
}

.bil-summary-value {
    margin: 2px 0;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--app-text-strong);
    overflow-wrap: anywhere;
}

/* ===========
     summary
   =========== */


/* The filter is the platform's glass toolbar as it is (WebbuilderUI css/app-toolbar.css) */

/* =========
     table
   ========= */

/* One set of columns for the whole table: every row (the head too) lays its cells on the table's own tracks (subgrid),
   so a column is as wide in every row and the head stays over its data, whatever each row's actions take */
.bil-table {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 0.9fr) auto;
    column-gap: 16px;
    border: 1px solid var(--app-line);
    border-radius: 22px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-soft);
    overflow: hidden;
}

.bil-row {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
    row-gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--app-line);
    transition: background-color 0.2s ease;
}

.bil-row:last-child {
    border-bottom: 0;
}

@media (hover: hover) {
    .bil-row:not(.bil-row-head):not(.bskel-row):hover {
        background: var(--app-bg-soft);
    }
}

.bil-row-head {
    padding-top: 12px;
    padding-bottom: 12px;
    background: var(--app-bg-soft);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.bil-cell {
    min-width: 0;
}

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

.bil-actions-head {
    text-align: right;
}

.bil-invoice {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bil-invoice-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--app-accent-soft);
    font-size: 20px;
    color: var(--app-accent);
}

.bil-invoice-text,
.bil-dates {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* The invoice number is never cut short: where the column is narrower than it, it breaks after one of its hyphens */
.bil-number {
    font-size: 14.5px;
    font-weight: 600;
    overflow-wrap: anywhere;
    color: var(--app-text-strong);
}

.bil-type,
.bil-sub {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--app-text-muted);
}

.bil-dates {
    font-size: 13.5px;
    color: var(--app-text);
}

/* The amount keeps a little room from the status beside it */
.bil-row > :nth-child(3) {
    padding-right: 16px;
}

.bil-total {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--app-text-strong);
}

.bil-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.bil-not-payable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--app-text-muted);
    white-space: nowrap;
    cursor: help;
}

.bil-not-payable:focus-visible {
    border-radius: 6px;
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* =========
     table
   ========= */


/* =================
     empty states
   ================= */

.bil-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 520px;
    margin: 32px auto 0;
    padding: 40px 28px;
    border: 1px dashed var(--app-line);
    border-radius: 24px;
    text-align: center;
}

.bil-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: var(--app-accent-soft);
    font-size: 28px;
    color: var(--app-accent);
}

.bil-empty-title {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 600;
    color: var(--app-text-strong);
}

.bil-empty-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--app-text-muted);
}

.bil-quiet {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px 18px;
    border: 1px dashed var(--app-line);
    border-radius: 16px;
    font-size: 14px;
    color: var(--app-text-muted);
}

.bil-quiet .bx {
    font-size: 18px;
    color: var(--app-accent);
}

/* =================
     empty states
   ================= */


/* ==============
     responsive
   ============== */

/* Tablet: the date and status share a column under the invoice */
@media (max-width: 1199.98px) {
    .bil-table {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.2fr) minmax(0, 0.9fr) auto;
    }

    /* Every cell names its column (the head's too): a grid places cells with a set row before the others, so a cell
       left to find its own place would land in another column than the same cell of the next row */
    .bil-row > :nth-child(1) {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .bil-row > :nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .bil-row > :nth-child(3) {
        grid-column: 3;
        grid-row: 1 / span 2;
    }

    .bil-row > :nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .bil-row > :nth-child(5) {
        grid-column: 4;
        grid-row: 1 / span 2;
    }

    /* The head is one line: its status heading folds away, the rest stays on the first row */
    .bil-row-head > :nth-child(4) {
        display: none;
    }

    .bil-row.bil-row-head > * {
        grid-row: 1;
    }
}

/* Phone: one card per invoice, the actions across the bottom */
@media (max-width: 767.98px) {
    /* Each card lays out its own two columns */
    .bil-table {
        display: block;
        border: 0;
        background: none;
        box-shadow: none;
        overflow: visible;
    }

    .bil-row-head {
        display: none;
    }

    .bil-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 12px;
        margin-bottom: 12px;
        padding: 16px;
        border: 1px solid var(--app-line);
        border-radius: 20px;
        background: var(--app-surface);
        box-shadow: var(--app-shadow-soft);
    }

    .bil-row:last-child {
        margin-bottom: 0;
        border-bottom: 1px solid var(--app-line);
    }

    .bil-row > .bil-invoice {
        grid-column: 1;
        grid-row: 1;
    }

    .bil-row > :nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    .bil-row > .bil-dates {
        grid-column: 1;
        grid-row: 2;
    }

    .bil-row > :nth-child(4) {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
    }

    .bil-row > .bil-actions {
        grid-column: 1 / -1;
        grid-row: 3;
        justify-content: stretch;
        padding-top: 4px;
    }

    .bil-actions .app-btn {
        flex: 1 1 auto;
    }

    .bil-summary {
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bil-row {
        transition: none;
    }
}
