/* /assets/css/autocomplete.css */
/* Estilos modernos y desacoplados para el componente CRMAutocomplete */

.crm-autocomplete-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
    font-family: inherit;
}

/* Encabezado / Barra superior opcional */
.crm-ac-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.crm-ac-label {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

.crm-ac-counter {
    font-size: 12px;
    color: #007bff;
    font-weight: 500;
    transition: color 0.2s ease;
}

.crm-ac-counter.is-empty {
    color: #94a3b8;
}

/* Contenedor de Etiquetas Seleccionadas (Modo Múltiple) */
.crm-ac-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 38px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    align-items: center;
    transition: all 0.2s ease;
}

.crm-ac-tags-container:hover {
    border-color: #94a3b8;
}

.crm-ac-empty-placeholder {
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
    padding-left: 4px;
    user-select: none;
}

/* Chip / Etiqueta */
.crm-ac-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    animation: crmAcPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.2s ease;
    max-width: 100%;
}

.crm-ac-chip--global {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.crm-ac-chip:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.crm-ac-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-ac-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.crm-ac-chip-remove:hover {
    background: rgba(220, 38, 38, 0.2);
    color: #dc2626;
    transform: scale(1.15);
}

@keyframes crmAcPopIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Caja de Búsqueda */
.crm-ac-box {
    position: relative;
    width: 100%;
}

.crm-ac-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.crm-ac-input {
    width: 100%;
    padding: 12px 38px 12px 38px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #ffffff;
    color: #1e293b;
}

.crm-ac-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.crm-ac-search-icon {
    position: absolute;
    left: 12px;
    color: #94a3b8;
    font-size: 15px;
    pointer-events: none;
    user-select: none;
}

.crm-ac-clear-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
    transition: color 0.15s;
}

.crm-ac-clear-btn:hover {
    color: #475569;
}

/* Menú Desplegable Flotante */
.crm-ac-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    animation: crmAcFadeInDown 0.15s ease-out;
}

/* Scrollbar estilizado */
.crm-ac-dropdown::-webkit-scrollbar {
    width: 6px;
}
.crm-ac-dropdown::-webkit-scrollbar-track {
    background: #f8fafc;
}
.crm-ac-dropdown::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.crm-ac-dropdown::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@keyframes crmAcFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crm-ac-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13.5px;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s ease;
    user-select: none;
}

.crm-ac-item:last-child {
    border-bottom: none;
}

.crm-ac-item:hover,
.crm-ac-item.is-highlighted {
    background-color: #f1f5f9;
    color: #0f172a;
}

.crm-ac-item.is-highlighted {
    background-color: #e0f2fe;
    color: #0369a1;
}

.crm-ac-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-ac-item-tag {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 12px;
    background: #e2e8f0;
    color: #475569;
    font-weight: 500;
    flex-shrink: 0;
    margin-left: 8px;
}

.crm-ac-item--global .crm-ac-item-tag {
    background: #dcfce7;
    color: #166534;
}

.crm-ac-match {
    font-weight: bold;
    color: #0284c7;
    text-decoration: underline;
}

.crm-ac-empty-state {
    padding: 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    font-style: italic;
}

/* Barra inferior de acciones y consejos */
.crm-ac-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12.5px;
    color: #64748b;
}

.crm-ac-clear-all-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: none;
    transition: background 0.15s;
}

.crm-ac-clear-all-btn:hover {
    background: #fee2e2;
}

/* Estado de error / validación */
.crm-autocomplete-wrapper.has-error .crm-ac-input,
.crm-autocomplete-wrapper.has-error .crm-ac-tags-container {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}
