/* ============================================================
   multi-invoice.css — MULTI-INVOICE-1
   Global styles for MultiInvoicePanel and sub-components.
   Design tokens mirror Review.razor.css (rv-* classes).
   DO NOT add scoping — these must reach inside child components.
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
/* card-border: #e2e8f0   card-radius: 10px                     */
/* header-bg:   #f1f5f9   title-color: #1a3c6e                  */
/* label-gray:  #94a3b8   input-border: #e2e8f0                 */
/* focus-blue:  #3b82f6   table-hd-bg: #f4f7fc                  */
/* row-border:  #f0f3f8   row-hover:   #f5f9ff                  */
/* zebra:       #fafafa   text-main:   #2c3e5a                   */

/* ── Panel container (wraps the entire multi-invoice area) ─── */

.mi-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

/* ── Panel header (matches rv-card-header) ────────────────── */

.mi-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.5rem;
}

.mi-panel-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.83rem;
    font-weight: 700;
    color: #1a3c6e;
    letter-spacing: 0.01em;
}

/* ── Alert bar ────────────────────────────────────────────── */

.mi-alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    border-bottom: 1px solid transparent;
}

.mi-alert-danger {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.mi-alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 0.85rem;
    padding: 0 0.25rem;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.mi-alert-close:hover { opacity: 1; }

/* ── Loading state ────────────────────────────────────────── */

.mi-loading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 1rem;
    font-size: 0.82rem;
    color: #6b7280;
    font-style: italic;
}

/* ── Shared buttons ───────────────────────────────────────── */

.mi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.2;
}

.mi-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mi-btn-primary {
    background: #1a3c6e;
    color: #fff;
}

.mi-btn-primary:not(:disabled):hover { background: #153060; }

.mi-btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.mi-btn-secondary:not(:disabled):hover {
    background: #e9f0f8;
    border-color: #94a3b8;
}

.mi-btn-danger {
    background: transparent;
    color: #9e9e9e;
    border: 1px solid transparent;
    font-size: 1rem;
}

.mi-btn-danger:not(:disabled):hover {
    color: #d32f2f;
    background: #fff5f5;
    border-color: #fecaca;
}

.mi-btn-sm {
    padding: 0.25rem 0.65rem;
    font-size: 0.77rem;
}

.mi-btn-xs {
    padding: 0.15rem 0.45rem;
    font-size: 0.73rem;
    border-radius: 4px;
}

/* ── Badges ───────────────────────────────────────────────── */

.mi-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

.mi-badge-info {
    background: #e8edf5;
    color: #1a3c6e;
}

.mi-badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.mi-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Warning icon inside invoice title */
.mi-warn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 9999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-style: normal;
    cursor: default;
}

/* ── Invoice card ─────────────────────────────────────────── */

.mi-invoice-card {
    border-top: 1px solid #e2e8f0;
}

.mi-invoice-card:first-of-type { border-top: none; }

.mi-invoice-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    cursor: default;
    user-select: none;
    min-height: 42px;
}

.mi-invoice-card-header:hover { background: #f1f5f9; }

.mi-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 0.75rem;
    padding: 2px 4px;
    border-radius: 3px;
    transition: color 0.15s;
    flex-shrink: 0;
}

.mi-collapse-btn:hover { color: #1a3c6e; }

.mi-invoice-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1a3c6e;
    flex: 1;
    min-width: 0;
}

.mi-invoice-card-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

/* Save / saved indicators */
.mi-saving-indicator,
.mi-saved-indicator {
    font-size: 0.73rem;
    font-weight: 500;
    white-space: nowrap;
}

.mi-saving-indicator { color: #6b7280; }
.mi-saved-indicator  { color: #16a34a; }

/* ── Invoice card body ────────────────────────────────────── */

.mi-invoice-card-body {
    padding: 0.75rem 1rem 0.85rem;
    border-top: 1px solid #f0f3f8;
    background: #fff;
}

/* ── Field grid (2-col, matches rv-fields-grid) ───────────── */

.mi-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.mi-field {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.mi-label {
    font-size: 0.69rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

/* ── Inputs (matches rv-field-input) ──────────────────────── */

.mi-input {
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 0.3rem 0.5rem;
    font-size: 0.84rem;
    color: #1e293b;
    background: #f8fafc;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.mi-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.mi-input-warn {
    border-color: #f59e0b !important;
    background: #fffbeb !important;
}

.mi-input-sm {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}

/* ── Delete confirm overlay ───────────────────────────────── */

.mi-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
}

.mi-confirm-box {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    max-width: 380px;
    width: 90%;
    text-align: center;
}

.mi-confirm-box p {
    font-size: 0.88rem;
    color: #1e293b;
    margin-bottom: 1.1rem;
    line-height: 1.5;
}

.mi-confirm-box small {
    color: #64748b;
    font-size: 0.78rem;
}

.mi-confirm-actions {
    display: flex;
    gap: 0.65rem;
    justify-content: center;
}

/* ── Line item tables (shared by both InvoiceLineItemsTable   */
/*    and UnassignedLineItemsPanel)                           */
/* ─────────────────────────────────────────────────────────── */

.mi-line-table-wrap {
    overflow-x: auto;
}

.mi-line-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: auto;
}

.mi-line-table thead tr {
    background: #f4f7fc;
    border-bottom: 2px solid #dde3ef;
}

.mi-line-table th {
    padding: 7px 12px;
    font-weight: 600;
    font-size: 0.73rem;
    color: #5a6a84;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    text-align: left;
}

.mi-line-table tbody tr {
    border-bottom: 1px solid #f0f3f8;
    transition: background 0.1s;
}

.mi-line-table tbody tr:last-child { border-bottom: none; }

.mi-line-table tbody tr:hover { background: #f5f9ff; }

.mi-line-table td {
    padding: 6px 12px;
    color: #2c3e5a;
    vertical-align: middle;
    font-size: 0.82rem;
}

/* Zebra striping */
.mi-line-table tbody tr:nth-child(even) { background-color: #fafafa; }
.mi-line-table tbody tr:nth-child(even):hover { background-color: #f5f9ff; }

/* ── Column alignment helpers ─────────────────────────────── */

.mi-lh-right  { text-align: right !important; }
.mi-lh-center { text-align: center !important; }
.mi-lh-check  { width: 40px; text-align: center; }

/* ── Move-to-unassigned action column ─────────────────────── */

.mi-lh-actions {
    width: 52px;
    text-align: center;
}

/* ── Selected row (unassigned panel) ──────────────────────── */

.mi-row-selected {
    background: #eff6ff !important;
    outline: 1px solid #bfdbfe;
    outline-offset: -1px;
}

.mi-row-selected:hover { background: #dbeafe !important; }

/* ── Empty states ─────────────────────────────────────────── */

.mi-empty-lines {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 14px 16px;
    font-size: 0.83rem;
    color: #8a98b0;
    font-style: italic;
}

.mi-empty-lines-sm {
    padding: 10px 14px;
    font-size: 0.80rem;
}

.mi-empty-hint {
    font-size: 0.78rem;
    color: #a0aec0;
}

/* ── Unassigned panel ─────────────────────────────────────── */

.mi-unassigned-panel {
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
}

.mi-unassigned-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    background: #f7f9fc;
    border-bottom: 1px solid #eaedf3;
    min-height: 42px;
}

.mi-unassigned-title {
    font-size: 0.80rem;
    font-weight: 700;
    color: #1a3c6e;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ── Bulk assign bar ──────────────────────────────────────── */

.mi-bulk-assign {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-left: auto;
    font-size: 0.80rem;
    color: #475569;
}

.mi-bulk-assign select.mi-input {
    width: auto;
    min-width: 180px;
}

/* ── Collapsed / expanded state (visual cue only) ─────────── */

.mi-collapsed .mi-invoice-card-body { display: none; }
.mi-expanded  .mi-invoice-card-body { display: block; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 900px) {
    .mi-field-grid {
        grid-template-columns: 1fr;
    }

    .mi-bulk-assign {
        margin-left: 0;
        width: 100%;
    }
}

/* ── Editable line-item inputs (InvoiceLineItemsTable) ─────── */

.mi-li-input {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.82rem;
    font-family: inherit;
    color: #1e2d45;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
    min-width: 0;
}

.mi-li-input:hover {
    border-color: #c9d8ef;
    background: #f8fafc;
}

.mi-li-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.mi-li-input-wide  { min-width: 80px; }
.mi-li-input-mono  { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.78rem; }
.mi-li-input-num   { text-align: right; max-width: 90px; }

/* ── Editable table column widths ─────────────────────────── */

.mi-line-table-editable { table-layout: fixed; }

.mi-li-col-desc  { width: 30%; }
.mi-li-col-sku   { width: 16%; }
.mi-li-col-num   { width: 80px; }
.mi-li-col-hs    { width: 100px; }
