/* =================================================================
   chip-input.css — Chip-style multi-value input (with autocomplete).
   Used inside the tag editor for list-like fields (artist, genre,
   composer, …). Host container is `.tag-chip-host`; the widget paints
   chips + a typing slot + a suggestions dropdown inside it.
   ================================================================= */

/* =================================================================
   ChipInput — chip-style multi-value input with autocomplete
   ================================================================= */

/* Host container (lives inside .tag-field). The ChipInput widget appends
   its own DOM underneath, so the host itself has no chrome. */
.tag-chip-host {
    display: block;
}

.tag-chip-host.tag-mixed .chip-input-field {
    border-color: rgba(var(--accent-purple-rgb), 0.45);
    background: rgba(var(--accent-purple-rgb), 0.05);
}

/* "Clear field" action for mixed host fields — small ghost button that
   sits below the chips so the user can blank a tag that only shows
   "(multiple values)". Toggles to "Restore" once cleared. */
.chip-clear-btn {
    margin-top: 6px;
    padding: 2px 8px;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-muted);
    background: transparent;
    border: 1px dashed var(--border-subtle);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.chip-clear-btn:hover {
    color: var(--danger, #cf6679);
    border-color: var(--danger, #cf6679);
}

.chip-clear-btn[data-cleared="true"] {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Scalar fields (non-chip inputs/textareas/hero): the same clear/restore
   strip sits below the control, full-width so it reads as an action for the
   whole field rather than a floating tag. */
label + .label-field-clear-btn,
.label-field-clear-btn {
    display: block;
    width: fit-content;
}

/* Chip-based fields intentionally do NOT get the orange "edited" accent —
   chips carry their own visual identity (the pill styling) and the
   accent line would duplicate that signal. */

.chip-input {
    position: relative;
    width: 100%;
}

.chip-input-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 5px 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: text;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.chip-input-field:focus-within {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.04);
}

/* .chip-input-dirty no longer changes the field border/background —
   chips are their own visual signal and an accent line would duplicate it. */

.chip-input-chips {
    display: contents;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    background: rgba(var(--accent-purple-rgb), 0.18);
    border: 1px solid rgba(var(--accent-purple-rgb), 0.35);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.2;
    max-width: 100%;
    user-select: none;
    transition: background 0.15s ease;
}

.chip:hover {
    background: rgba(var(--accent-purple-rgb), 0.28);
}

.chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.chip-editable {
    cursor: pointer;
}

.chip-editable:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.chip.chip-editing {
    background: rgba(var(--accent-primary-rgb), 0.18);
    border-color: var(--accent-primary);
    padding-right: 8px;
}

.chip-edit-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font: inherit;
    padding: 0;
    min-width: 60px;
    max-width: 320px;
}

.chip-remove {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 50%;
    transition: color 0.15s ease, background 0.15s ease;
}

.chip-remove:hover {
    color: var(--text-on-accent);
    background: var(--border-strong);
}

.chip-input-text {
    flex: 1 1 80px;
    min-width: 80px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 4px 2px;
}

.chip-input-text::placeholder {
    color: var(--text-muted);
}

.chip-input-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 10;
    padding: 4px;
}

.chip-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s ease;
}

.chip-opt:hover,
.chip-opt.chip-opt-hover {
    background: var(--bg-card-hover);
}

.chip-opt-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-opt-kind {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-cyan);
    background: rgba(var(--accent-cyan-rgb), 0.1);
    padding: 2px 6px;
    border-radius: 10px;
}

.chip-opt-count {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 24px;
    text-align: right;
}

.chip-opt-create {
    color: var(--accent-primary);
    font-style: italic;
}

.chip-opt-create .chip-opt-name {
    color: var(--accent-primary);
}

/* "Show all suggestions" footer row in the chip / autocomplete dropdowns */
.chip-opt-showall {
    border-top: 1px solid var(--border-subtle);
    margin-top: 4px;
    padding-top: 8px;
    color: var(--accent-cyan);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.chip-opt-showall .chip-opt-name {
    color: var(--accent-cyan);
}

.chip-opt-showall:hover {
    background: rgba(var(--accent-cyan-rgb), 0.08);
}
