/* Product lookup modal — shared widget styles.
   Originally lived in crm/css/hub.css (compose-only). Lifted to common so the
   global header icon and CRM compose can use the same markup. */

/* Larger modal frame for the lookup view. The base .ecb-modal in
   components.css is 600px — that's too cramped for the product table. */
.ecb-modal--plookup {
    width: 90%;
    max-width: 900px;
    height: 85vh;
}

.ecb-modal-body:has(.ecb-plookup-search) {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ecb-plookup-search {
    flex: 0 0 auto;
}

.ecb-plookup-search input {
    width: 100%;
}

.ecb-plookup-results {
    flex: 1 1 0;
    min-height: 0;
    background: var(--theme-bg-elevated);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    overflow-y: auto;
}

.ecb-plookup-results:empty {
    visibility: hidden;
}

.ecb-plookup-options {
    flex: 0 0 auto;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.ecb-plookup-table-wrapper {
    flex: 0 0 auto;
    overflow-y: auto;
    max-height: 30vh;
}

.ecb-plookup-table {
    font-size: 0.85rem;
}

.ecb-plookup-table th {
    white-space: nowrap;
}

.ecb-plookup-desc-row td {
    background: var(--theme-bg);
}

.ecb-plookup-desc-input {
    font-style: italic;
    width: 100%;
}

.ecb-plookup-qty {
    text-align: center;
}

.ecb-plookup-loading {
    padding: 0.5rem 0.75rem;
    text-align: center;
    color: var(--theme-fg-muted);
    font-size: 0.8rem;
}

.ecb-product-result {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--theme-border);
    font-size: 0.85rem;
}

.ecb-product-result:last-child {
    border-bottom: none;
}

.ecb-product-result:hover {
    background: var(--theme-bg);
}

.ecb-product-result-details {
    font-size: 0.75rem;
    color: var(--theme-fg-muted);
}

.ecb-product-result.is-unsynced {
    cursor: not-allowed;
    opacity: 0.55;
    background: var(--theme-bg);
}

.ecb-product-result.is-unsynced:hover {
    background: var(--theme-bg);
}

.ecb-product-result-warning {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* Global-mode "include product table" checkbox — sits inline next to Copy
   so the toggle is visually grouped with the action it modifies. */
.ecb-plookup-include-table {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* The modal footer lives inside .twp on modern shells, where
   `.twp button { padding: 0; background: none; color: inherit; }` strips
   button styling. Re-apply .ecb-btn primitives with two-class specificity
   so they win over the .twp reset. */
.ecb-modal-footer .ecb-btn,
.ecb-modal-footer button.ecb-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    background: var(--theme-bg-subtle, #f1f5f9);
    color: var(--theme-fg, #0f172a);
    cursor: pointer;
}
.ecb-modal-footer button.ecb-btn-primary {
    background: var(--header-bg, #417690);
    color: #fff;
}
.ecb-modal-footer button.ecb-btn:hover {
    background: var(--theme-border, #e2e8f0);
}
.ecb-modal-footer button.ecb-btn-primary:hover {
    background: #205067;
}
.ecb-modal-footer button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Totals row at the bottom of the basket table. */
.ecb-plookup-table tfoot td {
    border-top: 2px solid var(--theme-border, #e2e8f0);
    font-weight: 600;
    padding-top: 0.5rem;
}

/* Qty in the totals row gets a 60px centered span so the digit lines up
   with the qty input boxes in the body rows above (input is also 60px,
   text-align: center via .ecb-plookup-qty). */
.ecb-plookup-totals-qty {
    display: inline-block;
    width: 60px;
    text-align: center;
}

/* Sale-price styling — original price struck through next to the active
   sale price. Subtler colour so the eye lands on the discounted amount. */
.ecb-plookup-sale-original {
    color: var(--theme-fg-muted, #64748b);
    margin-right: 4px;
}

/* Danger styling for the two-click Clear confirm. */
.ecb-modal-footer button.ecb-btn-danger {
    background: #b91c1c;
    color: #fff;
}
.ecb-modal-footer button.ecb-btn-danger:hover { background: #991b1b; }

/* Header trigger button — basket icon + count badge */
.ecb-plookup-trigger {
    position: relative;
}

.ecb-plookup-trigger-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9999px;
    background: var(--ecb-primary, #417690);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ecb-plookup-trigger-badge[hidden] {
    display: none;
}

/* Lightweight toast for clipboard feedback. */
.ecb-plookup-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--theme-fg, #0f172a);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3);
    z-index: 11000;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.ecb-plookup-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.ecb-plookup-toast.is-error {
    background: #b91c1c;
}
