/* Helios linkage chip (krok 4c).
 *
 * Visual indicator that a form field is bound to a real Helios record.
 * Iterate VISUAL ONLY here -- behavior is in helios_chip.js, structure
 * is in partials/_helios_chip.html. Keep wiring out of this stylesheet.
 */

.helios-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    user-select: none;
    max-width: 100%;
}

.helios-chip__icon {
    font-weight: 700;
    display: inline-block;
    width: 1em;
    text-align: center;
}

.helios-chip__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 22em;
}

.helios-chip__id {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 11px;
    opacity: 0.75;
}

.helios-chip__unlink {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    color: inherit;
    opacity: 0.55;
}
.helios-chip__unlink:hover {
    opacity: 1;
}

/* States ---------------------------------------------------------------- */

.helios-chip--matched {
    background: #e8f5e9;
    color: #1b5e20;
    border-color: #c8e6c9;
}

.helios-chip--unmatched {
    background: #fff3e0;
    color: #e65100;
    border-color: #ffe0b2;
}
.helios-chip--unmatched .helios-chip__unlink {
    display: none;   /* nothing to unlink when not matched */
}

.helios-chip--fuzzy {
    background: #fff8e1;
    color: #ff8f00;
    border-color: #ffecb3;
}

/* Compact variant (used inside lines table rows) ------------------------ */

.helios-chip--product.helios-chip--matched,
.helios-chip--product.helios-chip--fuzzy,
.helios-chip--product.helios-chip--unmatched {
    /* tighter in line rows */
    padding: 1px 6px;
    font-size: 11px;
}

/* Product autocomplete dropdown (companion to the chip) -----------------
 * `position: fixed` (not absolute) so the dropdown escapes the
 * .review-lines-scroll overflow context. The scroll wrapper has
 * `overflow-x: auto`, which per CSS spec coerces overflow-y to clip
 * too -- with `position: absolute` the dropdown would render but be
 * cut off beyond the row's bottom edge. JS positions it just below
 * the triggering input on each HTMX swap (see helios_chip.js).
 */

.product-options {
    position: fixed;
    z-index: 100;
    background: #fff;
    border: 1px solid var(--line, #ddd);
    border-radius: 4px;
    margin: 0;
    padding: 2px 0;
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    min-width: 18em;
    /* Hidden by default; revealed when populated via HTMX. */
}
.product-options:empty {
    display: none;
}
.product-option {
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.product-option:hover {
    background: #f5f5f5;
}
.product-option strong {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 12px;
}
.product-option .muted {
    font-size: 11px;
    color: var(--muted, #666);
}
.product-options .no-results {
    padding: 6px 8px;
    color: var(--muted, #666);
    font-style: italic;
    cursor: default;
}
.product-options .no-results:hover {
    background: transparent;
}
