/* Invoice EDITOR redesign. Scoped under .ive (added in pages/bill/wrapper.blade.php),
 * reuses the --ivw-* tokens of invoice-view.css. Remove the .ive class to undo. */
body.invoice .ive { max-width: 1240px; margin: 0 auto; padding-bottom: 24px; color: var(--ivw-text); }
body.invoice .ive > .ivw-masthead { padding: 16px 0 4px; align-items: center; }
body.invoice .ive #list-page-actions-container { flex: 0 1 auto; width: auto; max-width: 100%; padding: 0; }
body.invoice .ive > .ive-body { padding-top: 12px; }

/* the one big sheet becomes separate cards */
body.invoice .ive .invoice-wrapper { max-width: none; padding: 0; margin: 0; background: transparent; border: 0; box-shadow: none; }
body.invoice .ive #invoice-wrapper > .billing-mode-only-item:first-child,
body.invoice .ive #invoice-wrapper > hr { display: none; }
body.invoice .ive #invoice-wrapper > .row { margin: 0; }
body.invoice .ive #invoice-wrapper > .row > .col-12 {
    background: var(--ivw-surface); border: 1px solid var(--ivw-line); padding: 20px 24px; margin: 0 0 16px !important;
    border-radius: 8px;
}
body.invoice .ive h3, body.invoice .ive h4 { color: var(--ivw-text); font-weight: 620; font-size: 16.5px; }

/* parties */
body.invoice .ive #invoice-wrapper > .row > .col-12:first-child { display: flex; flex-wrap: wrap; gap: 24px; }
body.invoice .ive #invoice-wrapper > .row > .col-12:first-child > div { float: none; flex: 1 1 260px; text-align: start !important; }
body.invoice .ive address { margin: 0; }
body.invoice .ive address h3, body.invoice .ive address h3.text-info { color: var(--ivw-text) !important; margin: 0 0 4px; }
body.invoice .ive address h4 { color: var(--ivw-brass); margin: 0 0 4px; }
body.invoice .ive address p { margin: 0 !important; color: var(--ivw-text-2) !important; line-height: 1.55; }

/* dates and balances */
body.invoice .ive #invoice-dates-wrapper { display: flex; flex-wrap: wrap; gap: 20px 32px; justify-content: space-between; }
body.invoice .ive #invoice-dates-wrapper > div { float: none; }
body.invoice .ive .invoice-dates { flex: 1 1 420px; max-width: 640px; }
body.invoice .ive .invoice-dates table, body.invoice .ive .invoice-dues table { display: block; }
body.invoice .ive .invoice-dates tbody, body.invoice .ive .invoice-dues tbody { display: flex; flex-wrap: wrap; gap: 16px; }
body.invoice .ive .invoice-dates tr { display: block; flex: 1 1 130px; }
body.invoice .ive .invoice-dues tr { display: block; }
body.invoice .ive #invoice-dates-wrapper td { display: block; padding: 0 !important; }
body.invoice .ive #invoice-dates-wrapper td:first-child { font-size: 13px; font-weight: 550; color: var(--ivw-text-2); margin-bottom: 5px; }
body.invoice .ive .invoice-dues td span { padding: 0 !important; line-height: 38px; font-size: 16px; }

/* inputs */
body.invoice .ive .form-control {
    background-color: var(--ivw-surface); color: var(--ivw-text); border: 1px solid var(--ivw-line);
    border-radius: 6px; min-height: 38px; font-size: 14.5px; box-shadow: none;
}
body.invoice .ive .form-control:focus { border-color: var(--ivw-brass); outline: 2px solid var(--ivw-brass); outline-offset: -1px; }
body.invoice .ive .form-control:disabled { background: transparent; border-color: transparent; font-weight: 620; text-align: end; opacity: 1; }

/* line items: the table and its add buttons read as one card */
body.invoice .ive .ive-items { padding: 0 !important; }
body.invoice .ive .invoice-table-wrapper { margin: 0; min-height: 0; }
body.invoice .ive .invoice-table { margin: 0; }
body.invoice .ive .invoice-table thead th {
    font-size: 13px; font-weight: 600; color: var(--ivw-text-2); background: var(--ivw-surface-2);
    border: 0 !important; padding: 11px 8px;
}
body.invoice .ive .invoice-table td { border: 0; border-bottom: 1px solid var(--ivw-hairline); padding: 12px 8px !important; margin: 0; }
body.invoice .ive .invoice-table td.x-action { white-space: nowrap; padding-inline-start: 18px !important; }
body.invoice .ive .invoice-table td.x-action button { margin: 0; border-color: transparent; }
body.invoice .ive .invoice-table td textarea { min-height: 62px; resize: vertical; }
body.invoice .ive .invoice-table tbody tr:hover { background: transparent; }
body.invoice .ive .invoice-item-actions { padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
body.invoice .ive .invoice-item-actions .btn { margin: 0; min-width: 0; padding: 7px 14px !important; border-radius: 6px; background: var(--ivw-surface); border: 1px solid var(--ivw-line); color: var(--ivw-text); box-shadow: none; }
body.invoice .ive .invoice-item-actions .btn:hover,
body.invoice .ive .invoice-item-actions .btn:focus { background: var(--ivw-surface-2) !important; color: var(--ivw-text) !important; border-color: var(--ivw-text-3) !important; }
body.invoice .ive .invoice-item-actions .btn i,
body.invoice .ive .invoice-item-actions .btn:hover i { color: var(--ivw-brass) !important; }

/* AI panel */
body.invoice .ive #iai-toggle, body.invoice .ive #iai-generate, body.invoice .ive #iai-insert {
    background: var(--ivw-brass); border-color: var(--ivw-brass); color: var(--ivw-brass-ink); border-radius: 6px; padding: 7px 14px;
}
body.invoice .ive #iai-panel { border: 1px solid var(--ivw-line) !important; border-radius: 8px; box-shadow: none; background: var(--ivw-surface); }
body.invoice .ive .ai-chip { border-color: var(--ivw-line); color: var(--ivw-text-2); background: var(--ivw-surface); }
body.invoice .ive .ai-chip.active { border-color: var(--ivw-brass); color: var(--ivw-brass); background: var(--ivw-surface-2); }
body.invoice .ive #iai-terms-out, body.invoice .ive #iai-notes-out { background: var(--ivw-surface-2) !important; }

/* totals, then tax / discount buttons under them */
body.invoice .ive #bill-totals-wrapper { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; border-bottom: 0 !important; border-radius: 8px 8px 0 0 !important; margin-bottom: 0 !important; }
body.invoice .ive #bill-totals-wrapper > div { float: none; margin: 0; }
body.invoice .ive #bill-totals-wrapper > div:last-child { margin-inline-start: auto; width: 340px; max-width: 100%; }
body.invoice .ive .invoice-total-table { width: 100%; font-variant-numeric: tabular-nums; }
body.invoice .ive .invoice-total-table td:first-child { text-align: start; color: var(--ivw-text-2); }
body.invoice .ive .invoice-total-table td:last-child { text-align: end; }
body.invoice .ive .invoice-total-table #billing-sums-total-container td { font-size: 22px !important; color: var(--ivw-text); padding-top: 10px; }
body.invoice .ive .bill-taxes-discounts-container { border-top: 0 !important; border-radius: 0 0 8px 8px !important; padding-top: 0 !important; text-align: end !important; }
body.invoice .ive .bill-taxes-discounts-container .btn { border-radius: 6px; padding: 6px 12px !important; margin: 4px 0 0 4px; font-size: 13.5px; }

/* terms and notes */
body.invoice .ive #bill-form-container > .invoice-wrapper ~ .invoice-wrapper {
    background: var(--ivw-surface); border: 1px solid var(--ivw-line); border-radius: 8px; padding: 20px 24px; margin-bottom: 16px;
}
body.invoice .ive .ive-old-buttons { display: none; }

/* save bar */
body.invoice .ive-bar {
    position: sticky; bottom: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    background: var(--ivw-surface); border: 1px solid var(--ivw-line); border-radius: 8px; padding: 12px 24px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
body.invoice .ive-bar .t { margin-inline-end: auto; color: var(--ivw-text-2); }
body.invoice .ive-bar .t b { color: var(--ivw-text); font-size: 20px; font-weight: 650; margin-inline-start: 8px; font-variant-numeric: tabular-nums; }
body.invoice .ive .ivw-btn { border-radius: 6px; }
body.invoice .ive .ivw-btn[disabled] { opacity: .6; }

/* phone: each line item stacks into a labelled block */
@media (max-width: 767px) {
    body.invoice .ive #invoice-wrapper > .row > .col-12 { padding: 16px; }
    body.invoice .ive #invoice-wrapper > .row > .ive-items { padding: 0 !important; }
    body.invoice .ive .invoice-table, body.invoice .ive .invoice-table tbody { display: block; }
    body.invoice .ive .invoice-table thead { display: none; }
    body.invoice .ive .invoice-table tr.billing-line-item { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--ivw-line); }
    body.invoice .ive .invoice-table tr.billing-line-item > td { display: block; border: 0; padding: 0 !important; min-width: 0 !important; width: auto; }
    body.invoice .ive .invoice-table tr.billing-line-item > td.hidden { display: none; }
    body.invoice .ive .invoice-table td.x-description { grid-column: 1 / -1; order: -1; }
    body.invoice .ive .invoice-table td.x-action { order: 9; align-self: end; }
    body.invoice .ive .invoice-table td.x-total { order: 8; }
    body.invoice .ive .invoice-table td.form-group::before { display: block; font-size: 12.5px; color: var(--ivw-text-2); margin-bottom: 3px; }
    body.invoice .ive td.x-description::before { content: var(--l-description); }
    body.invoice .ive td.x-quantity::before { content: var(--l-qty); }
    body.invoice .ive td.x-unit::before { content: var(--l-unit); }
    body.invoice .ive td.x-price::before { content: var(--l-rate); }
    body.invoice .ive td.x-tax::before { content: var(--l-tax); }
    body.invoice .ive td.x-total::before { content: var(--l-total); }
    body.invoice .ive-bar { padding-inline: 16px; }
    body.invoice .ive-bar .t { flex: 1 0 100%; }
    body.invoice .ive-bar .ivw-btn { flex: 1; justify-content: center; }
}
