/* ============================================================================
   JuiceCRM — Tag input con autocompletado (Zip 3)
   ----------------------------------------------------------------------------
   Componente reutilizable. Usa --primary, --border, --bg-card, etc. del
   app.css existente. No pisa selectores de otros componentes.
   ============================================================================ */

.tag-input {
    position: relative;
    background: #fff;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    min-height: 38px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    cursor: text;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-input:hover { border-color: var(--border-strong); }
.tag-input.focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(126, 104, 219, 0.12);
}

.tag-input-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    flex: 0 0 auto;
}

.tag-input-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #EDE9FB;
    color: #5B47BB;
    border: 0.5px solid #CFC4F1;
    line-height: 1.3;
    white-space: nowrap;
    user-select: none;
}

.tag-input-chip-x {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.55;
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    font-family: inherit;
}
.tag-input-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }

.tag-input-search {
    flex: 1 1 100px;
    min-width: 100px;
    border: none;
    outline: none;
    padding: 4px 6px;
    font-size: 13px;
    background: transparent;
    font-family: inherit;
    color: var(--text-primary);
}
.tag-input-search::placeholder { color: var(--text-tertiary); }

/* Dropdown */
.tag-input-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 200;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.tag-input.open .tag-input-dropdown { display: block; }

.tag-input-option {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 0.5px solid #F1F5F9;
}
.tag-input-option:last-child { border-bottom: none; }
.tag-input-option:hover,
.tag-input-option.active { background: #F8FAFC; }
.tag-input-option-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tag-input-option-name { flex: 1; color: var(--text-primary); }
.tag-input-option-meta { font-size: 11px; color: var(--text-tertiary); }

.tag-input-create {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 500;
    background: #FAFAFD;
    border-top: 0.5px solid var(--border);
}
.tag-input-create:hover { background: #F1EDFB; }
.tag-input-create-plus {
    display: inline-flex;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.tag-input-empty {
    padding: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.tag-input-loading {
    padding: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

/* Mantener el select multiple oculto pero accesible al form post */
.tag-input-hidden-select {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
